如何在C ++ / CLI中将图片从图片框转换为:: MAT?
谢谢
你需要投的Drawing.Image成位图(假定该图像确实是一个位图)。
然后锁定System.Drawing.Bitmap,并使用BitmapData的Scan0属性访问内部缓冲区。
System::Drawing::Bitmap ^ bitmapFrame = safe_cast< System::Drawing::Bitmap ^ >(pictureBox1->Image);
BitmapData^ bmpData = bitmapFrame->LockBits(gcnew Rectangle(0, 0, bitmapFrame->Width, bitmapFrame->Height), System::Drawing::Imaging::ImageLockMode::ReadWrite,
bitmapFrame->Format);
try
{
void* data = bmpData.Scan0;
//use the data in the ::Mat constructor.
}
finally { bitmapFrame->UnlockBits(bmpData); }//Remember to unlock!!!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句