When I was learning opencv, I wanted to display images in the standard window. After learning, I could display them in the dialog box.
However, the problem arises. When using opencv to process the image, call the opencv function:
Cvcvtcolor (IMG. getimage (), imgtemp, cv_bgr2gray );
The processed image is stored in imgtemp. When it is created, it is iplimage, but it is cvarr. You cannot use the drawtohdc () function of cvvimage. I think it may be that the constructor of the cvvimage class is not enough, so I inherited the cvvimage class
Class myimg: Public cvvimage
{
Public:
Myimg (iplimage * IMG): cvvimage ()
{
M_img = cvcloneimage (IMG );
}
};
The statement is as follows:
Imgtemp = cvcreateimage (cvsize (IMG. Width (), IMG. Height (), ipl_depth_8u, 1 );
Cvcvtcolor (IMG. getimage (), imgtemp, cv_bgr2gray); // RGB × interval» interval between years.
Crect rect (IMG. Width () * 0.5 + 10, 0, IMG. Width () + 10, IMG. Height () * 0.5 );
Myimg img1 (imgtemp );
Img1.drawtohdc (DC. getsafehdc (), rect );
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/polinzhuo/archive/2005/04/03/335183.aspx