summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-04-29 18:44:35 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-04-29 18:49:33 +0200
commit4a8aa4397aa578e19ce7e6a0b1fdd702bd4187d5 (patch)
tree20731fdd439c4309fbd471d2484a79d328e92292
parentce79d1556bf8d43665694d7dd75571a79d175615 (diff)
video: break camera API
-rw-r--r--tracker-easy/tracker-easy.cpp28
-rw-r--r--tracker-kinect-face/camera_kinect_ir.cpp16
-rw-r--r--video/camera.hpp18
3 files changed, 30 insertions, 32 deletions
diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp
index 84d14db0..0217b07f 100644
--- a/tracker-easy/tracker-easy.cpp
+++ b/tracker-easy/tracker-easy.cpp
@@ -125,23 +125,25 @@ namespace EasyTracker
// Create our camera matrix
iCameraMatrix.create(3, 3, CV_64FC1);
iCameraMatrix.setTo(cv::Scalar(0));
- iCameraMatrix.at<double>(0, 0) = iCameraInfo.focalLengthX;
- iCameraMatrix.at<double>(1, 1) = iCameraInfo.focalLengthY;
- iCameraMatrix.at<double>(0, 2) = iCameraInfo.principalPointX;
- iCameraMatrix.at<double>(1, 2) = iCameraInfo.principalPointY;
+ iCameraMatrix.at<double>(0, 0) = iCameraInfo.fx;
+ iCameraMatrix.at<double>(1, 1) = iCameraInfo.fy;
+ iCameraMatrix.at<double>(0, 2) = iCameraInfo.P_x;
+ iCameraMatrix.at<double>(1, 2) = iCameraInfo.P_y;
iCameraMatrix.at<double>(2, 2) = 1;
// Create distortion cooefficients
iDistCoeffsMatrix = cv::Mat::zeros(8, 1, CV_64FC1);
// As per OpenCV docs they should be thus: k1, k2, p1, p2, k3, k4, k5, k6
- iDistCoeffsMatrix.at<double>(0, 0) = 0; // Radial first order
- iDistCoeffsMatrix.at<double>(1, 0) = iCameraInfo.radialDistortionSecondOrder; // Radial second order
- iDistCoeffsMatrix.at<double>(2, 0) = 0; // Tangential first order
- iDistCoeffsMatrix.at<double>(3, 0) = 0; // Tangential second order
- iDistCoeffsMatrix.at<double>(4, 0) = 0; // Radial third order
- iDistCoeffsMatrix.at<double>(5, 0) = iCameraInfo.radialDistortionFourthOrder; // Radial fourth order
- iDistCoeffsMatrix.at<double>(6, 0) = 0; // Radial fith order
- iDistCoeffsMatrix.at<double>(7, 0) = iCameraInfo.radialDistortionSixthOrder; // Radial sixth order
+ // 0 - Radial first order
+ // 1 - Radial second order
+ // 2 - Tangential first order
+ // 3 - Tangential second order
+ // 4 - Radial third order
+ // 5 - Radial fourth order
+ // 6 - Radial fifth order
+ // 7 - Radial sixth order
+ for (unsigned k = 0; k < 8; k++)
+ iDistCoeffsMatrix.at<double>(k, 0) = (double)iCameraInfo.dist_c[k];
}
@@ -334,7 +336,7 @@ namespace EasyTracker
// Create OpenCV matrix from our frame
// TODO: Assert channel size is one or two
- iMatFrame = cv::Mat(iFrame.height, iFrame.width, CV_MAKETYPE((iFrame.channelSize == 2 ? CV_16U : CV_8U), iFrame.channels), iFrame.data, iFrame.stride);
+ iMatFrame = cv::Mat(iFrame.height, iFrame.width, CV_MAKETYPE((iFrame.channel_size == 2 ? CV_16U : CV_8U), iFrame.channels), iFrame.data, iFrame.stride);
iFrameCount++;
bool doPreview = check_is_visible();
diff --git a/tracker-kinect-face/camera_kinect_ir.cpp b/tracker-kinect-face/camera_kinect_ir.cpp
index 4d442bf2..a4e6b203 100644
--- a/tracker-kinect-face/camera_kinect_ir.cpp
+++ b/tracker-kinect-face/camera_kinect_ir.cpp
@@ -105,7 +105,7 @@ namespace Kinect {
iFrame.height = iHeight;
iFrame.stride = cv::Mat::AUTO_STEP;
iFrame.channels = iMatFrame.channels();
- iFrame.channelSize = iMatFrame.elemSize1();
+ iFrame.channel_size = iMatFrame.elemSize1();
return { iFrame, new_frame };
}
@@ -177,13 +177,13 @@ namespace Kinect {
hr = iCoordinateMapper->GetDepthCameraIntrinsics(&intrinsics);
if (SUCCEEDED(hr))
{
- aInfo.focalLengthX = intrinsics.FocalLengthX;
- aInfo.focalLengthY = intrinsics.FocalLengthY;
- aInfo.principalPointX = intrinsics.PrincipalPointX;
- aInfo.principalPointY = intrinsics.PrincipalPointY;
- aInfo.radialDistortionFourthOrder = intrinsics.RadialDistortionFourthOrder;
- aInfo.radialDistortionSecondOrder = intrinsics.RadialDistortionSecondOrder;
- aInfo.radialDistortionSixthOrder = intrinsics.RadialDistortionSixthOrder;
+ aInfo.fx = intrinsics.FocalLengthX;
+ aInfo.fy = intrinsics.FocalLengthY;
+ aInfo.P_x = intrinsics.PrincipalPointX;
+ aInfo.P_y = intrinsics.PrincipalPointY;
+ aInfo.dist_c[1] = intrinsics.RadialDistortionSecondOrder;
+ aInfo.dist_c[3] = intrinsics.RadialDistortionFourthOrder;
+ aInfo.dist_c[5] = intrinsics.RadialDistortionSixthOrder;
}
}
diff --git a/video/camera.hpp b/video/camera.hpp
index c08fedb1..9ff2821b 100644
--- a/video/camera.hpp
+++ b/video/camera.hpp
@@ -21,9 +21,8 @@ struct frame final
{
unsigned char* data = nullptr;
// the `stride' member can have a special value of zero,
- // signifying equal to width * element size
- int width = 0, height = 0, stride = 0, channels = 0;
- int channelSize = 1;
+ // signifying stride equal to width * element size
+ int width = 0, height = 0, stride = 0, channels = 0, channel_size = 1;
};
} // ns video
@@ -41,7 +40,7 @@ struct OTR_VIDEO_EXPORT camera_
virtual std::vector<QString> camera_names() const = 0;
virtual std::unique_ptr<camera> make_camera(const QString& name) = 0;
- [[nodiscard]] virtual bool show_dialog(const QString& camera_name) = 0;
+ virtual bool show_dialog(const QString& camera_name) = 0;
virtual bool can_show_dialog(const QString& camera_name) = 0;
};
@@ -49,14 +48,11 @@ struct OTR_VIDEO_EXPORT camera
{
struct info final
{
+ // TODO: expose FOV-based focal length for regular webcams
int width = 0, height = 0, fps = 0;
- float focalLengthX = 0.0f;
- float focalLengthY = 0.0f;
- float principalPointX = 0.0f;
- float principalPointY = 0.0f;
- float radialDistortionSecondOrder = 0.0f;
- float radialDistortionFourthOrder = 0.0f;
- float radialDistortionSixthOrder = 0.0f;
+ float fx = 0, fy = 0; // focal length
+ float P_x = 0, P_y = 0; // principal point
+ float dist_c[8] {}; // distortion coefficients
};
camera();