Ask Your Question
0

How should I copy "IplImage" to "CImage"?

asked 2013-09-02 01:16:50 -0600

zawpai gravatar image

Hi all,

Does anyone can give some suggestion or feedback to me? I get one problem for copying image. Actually, I would like to convert/set "IplImage" to "CImage" and then show at "Picture Box". Whenever I write TestImage->CopyOf(tempImage, 3);, application will get system error.

So, how should I do it?

Best regards,

edit retag flag offensive close merge delete

Comments

Actually I have no clue of CImage, but maybe you could use cv:.imencode to transform your image into a buffer and then read this buffer with an CImage object.

Moster gravatar imageMoster ( 2013-09-02 02:51:18 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-02 03:06:29 -0600

What you actually have to do is convert your image to the bitmap format then push it inside the CImage by assignment. This topic tells you more about the bitmap conversion.

However I suggest using the C++ interface Mat instead of the C interface IplImage. Because that element has a to bitmap functionality provided.

An example in Android I quickly grabbed of the net, but what will work if you take the corresponding C++ functions is showed here:

Bitmap bmp = null;
Mat tmp = new Mat (height, width, CvType.CV_8U, new Scalar(4));
try {
    Imgproc.cvtColor(original_image, tmp, Imgproc.COLOR_GRAY2RGBA, 4);
    bmp = Bitmap.createBitmap(tmp.cols(), tmp.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(tmp, bmp);
}
catch (CvException e){Log.d("Exception",e.getMessage());}
edit flag offensive delete link more

Comments

Hi Steven,

Thanks for your information. I can't use "Mat" structure because I am using OpvenCv1.0. Currently, I solve my problem by using membership function of "CImage", CImage->CopyOf(iplImage). Before doing "CImage->CopyOf()", I have to instantiate "CImage" first. It doesn't need to do any conversion.

Thanks and regards

zawpai gravatar imagezawpai ( 2013-09-02 22:36:44 -0600 )edit

Is there a reason why using the OpenCV1.0? Tons of bugs that are in that version, are fixed in later editions, let alone the C - API has been replaced with a better C++ API.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 02:13:51 -0600 )edit

Actually, I try to use higher version. But, I can't compile or create the library by using "cMake" in VC6.0. So, I am installing version1.0 and use it. I am not sure whether higher version will support VC6.0 or not. Is it possible to use library that is compiled from MSVC2010 in VC6.0 project?

zawpai gravatar imagezawpai ( 2013-09-03 07:48:05 -0600 )edit

If you load a VC6.0 project into visual studio 2010 it asks to switch to vc10 actually. But there is always backwards compatibility.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-03 08:33:35 -0600 )edit

Thanks for your feedback. I have another reason why I am using VC6.0. In our current project, my previous colleague used "Picolo Fram Grabber" to capture the image. Then, display and image processing was used other "Commercial Image Library". Now, I just want to replace OpenCv in existing project and I also have a time line. So, I don't want to change the platform.

zawpai gravatar imagezawpai ( 2013-09-03 19:38:51 -0600 )edit

Question Tools

Stats

Asked: 2013-09-02 01:16:50 -0600

Seen: 2,117 times

Last updated: Sep 02 '13