[英]opencv copy data from a *Mat to a Mat
I have two cv::Mat
objects: 我有两个
cv::Mat
对象:
cv::Mat *frameLeftRemap;
cv::Mat frameLeft2;
Data streams into *frameLeftRemap from a camera. 数据从摄像机流到* frameLeftRemap中。 I need to copy the data to frameLeft2, then delete frameLeftRemap, to avoid the frame artifacts I am seeing.
我需要将数据复制到frameLeft2,然后删除frameLeftRemap,以避免我看到的帧伪像。 (This was suggested by the camera manufacturer support desk.)
(这是由相机制造商支持部门建议的。)
the function is: 函数是:
void ProcessImageLeft(AVT::VmbAPI::FramePtr pFrame)
{
VmbUchar_t *pBuffer;
VmbUint32_t FrameWidth;
VmbUint32_t FrameHeight;
//prepare frame information:
pFrame->GetWidth(FrameWidth);
pFrame->GetHeight(FrameHeight);
pFrame->GetImage(pBuffer);
//edited
Mat1b imageL(FrameHeight, FrameWidth, (uchar*)pBuffer);
cv::remap(imageL, *frameLeftRemap, mx1, my1, cv::INTER_LINEAR);
frameLeft2 = frameLeftRemap->clone();
//frameLeftRemap->copyTo(frameLeft2);
cv::imshow("right", frameLeft2);
cv::waitKey(1);
delete frameLeftRemap;
}
both copyTo and clone give an error: copyTo和clone都给出一个错误:
this is nullPtr. read access violation
What am I doing wrong here? 我在这里做错了什么?
frameL= frameLeftRemap->clone();
should work correctly. 应该可以正常工作。 It seems you have problem in
frameL
. 看来您在
frameL
有问题。 Try to show it using cv::imshow
or cv::imwrite
to make sure it was corrupted before cloning it. 尝试使用
cv::imshow
或cv::imwrite
显示它,以确保在克隆之前损坏它。 Then fix the original problem. 然后解决原始问题。 If you posted code, we would help you more.
如果您发布了代码,我们将为您提供更多帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.