将函数openCV转换为openCvSharp

发布于 2025-01-26 08:00:31 字数 632 浏览 3 评论 0 原文

我有这个问题,我想在C#上使用cv :: initundistortrectifymap,并且我正在使用opencvSharp -cv2.InundundistOrtRectifyMap。该问题是参数“ InputArray R”不正确。有人为这个问题提供了例子。

这是C ++代码:

cv::initUndistortRectifyMap(mt, mtdist,cv::Mat(), cv::getOptimalNewCameraMatrix(mt, mtdist, imageSize, 1, imageSize, 0), imageSize, CV_16SC2, map1, map2);

这是C#代码:

Cv2.InitUndistortRectifyMap(mt, mtdist,map(wrong), Cv2.GetOptimalNewCameraMatrix(mt, mtdist, src.Size(), 1, src.Size(), out rect, false), src.Size(), MatType.CV_16SC2, map1, map2);

I have this issues, I want use to function cv::initUndistortRectifyMap on C# and I'm using Opencvsharp - Cv2.InitUndistortRectifyMap.The problem is parameters "inputarray r" not true. Somebody have example for this issues.

This is C++ code :

cv::initUndistortRectifyMap(mt, mtdist,cv::Mat(), cv::getOptimalNewCameraMatrix(mt, mtdist, imageSize, 1, imageSize, 0), imageSize, CV_16SC2, map1, map2);

This is C# code:

Cv2.InitUndistortRectifyMap(mt, mtdist,map(wrong), Cv2.GetOptimalNewCameraMatrix(mt, mtdist, src.Size(), 1, src.Size(), out rect, false), src.Size(), MatType.CV_16SC2, map1, map2);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女的英雄梦 2025-02-02 08:00:31

r 参数确实是可选的。它是用于其他立体声转换的。

您可以给它一个空的垫子或UMAT,根据文档,它将使用身份矩阵,而不做其他转换。

OPENCV文档:

代码示例:

Cv2.InitUndistortRectifyMap(
                CameraMatrix,
                DistortionMatrix,
                tokenTracker.NewUMat(),
                newCameraMatrix,
                newImageSize,
                MatType.CV_32F,
                map1,
                map2);

其中 tokentracker.newumat()

使用您的代码:

Cv2.InitUndistortRectifyMap(
                mt,
                mtdist,
                new Mat(),
                Cv2.GetOptimalNewCameraMatrix(
                    mt,
                    mtdist,
                    src.Size(),
                    1,
                    src.Size(),
                    out rect,
                    false),
                src.Size(),
                MatType.CV_16SC2,
                map1,
                map2);

注意:在此示例中,我没有使用 Resourcetracker 。因此, new Mat()具有不受管理的内存。

The r parameter is really an optional one. It's for additional stereo transformation.

You can give it an empty Mat or UMat and according to the documentation it will use the identity matrix instead, doing no additional transformation.

OpenCV documentation:
https://docs.opencv.org/3.4/da/d54/group__imgproc__transform.html#ga7dfb72c9cf9780a347fbe3d1c47e5d5a

Code Example:

Cv2.InitUndistortRectifyMap(
                CameraMatrix,
                DistortionMatrix,
                tokenTracker.NewUMat(),
                newCameraMatrix,
                newImageSize,
                MatType.CV_32F,
                map1,
                map2);

Where tokenTracker.NewUMat() is creating a new managed UMat via ResourcesTracker tokenTracker.

Using your code:

Cv2.InitUndistortRectifyMap(
                mt,
                mtdist,
                new Mat(),
                Cv2.GetOptimalNewCameraMatrix(
                    mt,
                    mtdist,
                    src.Size(),
                    1,
                    src.Size(),
                    out rect,
                    false),
                src.Size(),
                MatType.CV_16SC2,
                map1,
                map2);

Note: I did not used a ResourceTracker in this example. So the new Mat() has unmanaged memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文