背景
我试图从ArUco发送到使用其.dlls访问的OpenCV函数的图像数据中检测.dlls标记。
版本
OpenCV : 4.5.0/4.5.1
单位: 2020.1.17f1
Aruco字典: 6x6_250家族和AprilTags 36h11家族
问题
当我使用相机并发送每个帧时(如这里的代码所示),detectMarkers()函数可以工作,但是每个标记都会被拒绝。
我试过:
System.Array.Reverse(rawImg) *我也尝试过使用flip(imageCopy, imageCopy, -1)在c++中翻转图像,然后在图像之后返回到c++,这是在Unity中的组合。但我确保了'imshow()`.detectMarkers()函数的图像是正确的(即没有翻转),也从aruCo字典更改为4月标记,这样标签中就不会出现版本错配。imread()加载图像来检查。这是工作的,标签也会被检测到。此外,我还尝试发送单个图像数据(使用Texture2D作为图像类型)。这里的cvtColor()行崩溃了。。
统一代码片段的一部分
private WebCamTexture CamTexture;
void Start()
{
CamTexture = new WebCamTexture();
CamTexture.Play();
}
void Update()
{
if (CamTexture.isPlaying)
{
var rawImg = CamTexture.GetPixels32();
MarkersDetection.detectAruco(ref ArucoID, ref arrayLength, ref rawImg, WebcamWidth, WebcamHeight);
}
}OpenCV代码片段的一部分
struct Color32
{
uchar red;
uchar green;
uchar blue;
uchar alpha;
};
extern "C" void __declspec(dllexport) __stdcall detectAruco(int& outArucoID,int& arraySize,Color32 **rawImg,int width,int height) {
cv::Mat imageCopy;
cv::Mat image(height, width, CV_8UC4, *rawImg);
cvtColor(image, imageCopy, COLOR_BGRA2BGR);
cv::aruco::detectMarkers(imageCopy, arucoDictionary, arucoCorners, arucoIds, parameters, rejectedCandidates);
}发布于 2021-04-15 16:06:30
我做错了翻转动作!现在,我使用图像工具(任何翻转图像的编辑工具,而不是手动)翻转图像,现在它可以工作了。
https://stackoverflow.com/questions/67110066
复制相似问题