How to convert CBitmap to cv::Mat? Maybe there are some libs or something else... like...
CBitmap bitmap;
bitmap.CreateBitmap(128, 128, 1, 24, someData);
cv::Mat outBitmap(128,128,someData,1,24);
but that code is incorrect.
thanks!
How to convert CBitmap to cv::Mat? Maybe there are some libs or something else... like...
CBitmap bitmap;
bitmap.CreateBitmap(128, 128, 1, 24, someData);
cv::Mat outBitmap(128,128,someData,1,24);
but that code is incorrect.
thanks!
There is another way around, you can convert your
CBitmaptoHBitmap, then convertHBitmaptoGdiPlus::Bitmap, then convert it tocv::Mat. Here's what you can do, but beware, this solution only works for RGB24 pixel format :Step 1:
CBitmaptoHBITMAPStep 2:
HBITMAPtoGdiplus::Bitmap(copied from this question)Call this function and pass your
HBITMAPto it.Step 3:
Gdiplus::Bitmaptocv::MatPass the
Gdiplus::Bitmapthat you created in last step to this function and you will get yourcv:Mat. As I said before this function just works with RGB24 pixel format.