简体   繁体   中英

Convert Bitmap to OpenCvSharp IplImage

I'm unfortunately struggling with this. I have a project that is mixed with Emgu and OpenCvSharp. Sounds odd but there are reasons.

At any rate, what I have is an EMGU.CV.Image that I'd like to use to populate an OpenCvSharp IplImage

I'm assuming this is possible, however I cannot wrap my head around it.

Relevant snippet of code (C#):

            FrameCapture = Cv.CreateFileCapture(@"C:\test\vid1.mp4");

            var frm = cap.QueryFrame();
            var frameBmp = frm.Bitmap;

            IplImage curFrame = ??? <<====== I'd like to create curFrame based on frameBmp

As usual, the answer is always simple.

For anyone who encounters this problem, the following is what you can do:

            var frm = cap.QueryFrame(); // this is an Emgu.CV.Image object
            var frameBmp = frm.Bitmap; // this is the bitmap from that object

            Frame = new IplImage(frameBmp.Width, frameBmp.Height, BitDepth.U8, 3);  //creates the OpenCvSharp IplImage;
            Frame.CopyFrom(frameBmp); // copies the bitmap data to the IplImage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM