Home > Back-end >  C Builder with OpenCV and TBitmap display images
C Builder with OpenCV and TBitmap display images

Time:11-10

Baidu to code:
If (dlgOpenPic - & gt; The Execute ())//use TOpenDialog control select files
{
IplImage * pImage=cvLoadImage (dlgOpenPic - & gt; FileName. C_str (), CV_LOAD_IMAGE_COLOR);//using OPENCV function to load the picture
If (pImage==NULL)
return ;
CvFlip (pImage);
Int nWidth=pImage - & gt; Width;
Int nHeight=pImage - & gt; Height;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; Width=nWidth;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; Height=nHeight;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; PixelFormat=pf24bit;//set the picture is 24 color display
Memcpy (imgShowPic - & gt; Picture - & gt; Bitmap - & gt; ScanLine [] nHeight - 1, pImage - & gt; ImageData pImage - & gt; ImageSize);//will load the image data to the Timage control,

CvReleaseImage (& amp; PImage);//the end to release the handle,
}

So you can show the picture of any format,
-- -- -- -- -- -- -- -- -- --
Old shall see if there is something wrong with this code?
CvFlip (pImage);
Memcpy (imgShowPic - & gt; Picture - & gt; Bitmap - & gt; ScanLine [] nHeight - 1, pImage - & gt; ImageData pImage - & gt; ImageSize);
The principle of two lines of code? ScanLine] [nHeight - 1 is the lowest address? BMP scan line is reverse?

CodePudding user response:


BCB in using opencv display picture
Zh516846937 17:35:36 2011-11-23 2771 collection
Tags: work image null
Copyright

Create a new project, to add a Timage control (dlgOpenPic), a TOpenDialog control (dlgOpenPic), a button,

Add the following statement: in the header file
#include //it is to use OPENCV must use the file
# include "CV. H"
# include "highgui. H"
# include "cxcore. H"
# pragma link "cv200 lib"
# pragma link "cxcore200 lib"
# pragma link "highgui200 lib"
This is to join the required header files and LIB library, then cv200. DLL, cxcore200. DLL, highgui200. DLL in the working directory,
These will be set after finishing engineering:
Configuration:
The Project - & gt; The Options - & gt;" Directories/Conditionals
"Conditionals: _DEBUG; SKIP_INCLUDES (add SKIP_INCLUDES),
These are set up is to write code,

The click event of the button to add the following code:

If (dlgOpenPic - & gt; The Execute ())//use TOpenDialog control select files
{
//code in the main building

CodePudding user response:

Should be, cvLoadImage (dlgOpenPic - & gt; FileName. C_str (), CV_LOAD_IMAGE_COLOR) transformed into RGB3 channel the image bitmap formats, namely 24 bitmap, and then upside down, because the VCL TBitmap establish bitmap DIB by default, is the bottom - & gt; Stored in order top

CodePudding user response:

refer to the second floor early play big play nuclear response:
should be, cvLoadImage (dlgOpenPic - & gt; FileName. C_str (), CV_LOAD_IMAGE_COLOR) transformed into RGB3 channel the image bitmap formats, namely 24 bitmap, and then upside down, because the VCL TBitmap establish bitmap DIB by default, is the bottom - & gt; Stored in order top

On baidu, I CV_LOAD_IMAGE_COLOR: image into a color figure (BGR, 3 channels)
Bitmap - & gt; PixelFormat=pf24bit;
Both have RGB data byte sequence may be reversed, a RGB, a BGR arrangement?
ScanLine [nHeight - 1] why is lowest address?

CodePudding user response:

Both have RGB data byte sequence may be reversed, a RGB, a BGR arrangement?
===========================================
Unknown, but should not be on the truth, since it is converted into Windows BITMAP format, should be in accordance with the BITMAP byte order

ScanLine [nHeight - 1] why is lowest address?
============================
Because the DIB is bottom - & gt; Stored in the top, the bottom of a scan line data first store

CodePudding user response:

references 4 floor early play play nuclear response:
both have RGB data byte sequence may be reversed, a RGB, a BGR arrangement?
===========================================
Unknown, but should not be on the truth, since it is converted into Windows BITMAP format, should be in accordance with the BITMAP byte order

ScanLine [nHeight - 1] why is lowest address?
============================
Because the DIB is bottom - & gt; Stored in the top, the bottom of a scan line data storage first

Old is OpenCV environment can try this code?
  • Related