使用OpenCV開啟Camera後該如何取像?? |
尚未結案
|
abubuabubu
一般會員 發表:5 回覆:4 積分:1 註冊:2004-02-06 發送簡訊給我 |
以下是openCV開啟Camera的片段code
========================================================= CvCapture* capture = 0; capture = cvCaptureFromCAM(0); IplImage *frame; ------------------------------>opencv定義存放frame的地方 cvNamedWindow( "result", 0 ); ---------------->new一個windoe if( capture ) { for(;;) { //Edit1->Text=IntToStr(frame->nSize); if( !cvGrabFrame( capture )) break; frame = cvRetrieveFrame( capture ); if( !frame ) break; cvShowImage( "result", frame );----------->將frame丟到window並利用無限迴圈持續show if( cvWaitKey( 10 ) >= 0 ) break; } cvReleaseCapture( &capture ); } ========================================== Camera確實可以Show也可以控制PTZ 但是我希望將某一個frame,在Image元件上畫出來,也就是要取像 畫的方法例如: Image->Canvas->Pixels[x][y]=?????????????? 但是???????的地方卻不知道該如何取得IplImage *frame的RGB值 不知道有沒有高手會呢???為小弟解惑!!謝謝!! |
CoffeeX
中階會員 發表:18 回覆:121 積分:72 註冊:2005-02-18 發送簡訊給我 |
typedef struct _IplImage
{
int nSize; /* sizeof(IplImage) */
int ID; /* version (=0)*/
int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */
int alphaChannel; /* ignored by OpenCV */
int depth; /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
char colorModel[4]; /* ignored by OpenCV */
char channelSeq[4]; /* ditto */
int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels.
cvCreateImage can only create interleaved images */
int origin; /* 0 - top-left origin,
1 - bottom-left origin (Windows bitmaps style) */
int align; /* Alignment of image rows (4 or 8).
OpenCV ignores it and uses widthStep instead */
int width; /* image width in pixels */
int height; /* image height in pixels */
struct _IplROI *roi;/* image ROI. when it is not NULL, this specifies image region to process */
struct _IplImage *maskROI; /* must be NULL in OpenCV */
void *imageId; /* ditto */
struct _IplTileInfo *tileInfo; /* ditto */
int imageSize; /* image data size in bytes
(=image->height*image->widthStep
in case of interleaved data)*/
char *imageData; /* pointer to aligned image data */
int widthStep; /* size of aligned image row in bytes */
int BorderMode[4]; /* border completion mode, ignored by OpenCV */
int BorderConst[4]; /* ditto */
char *imageDataOrigin; /* pointer to a very origin of image data
(not necessarily aligned) -
it is needed for correct image deallocation */
}
IplImage;
是這個嗎?
frame->imageData[?]
用整個imageData copy 進到 Bitmap->ScanLine[] 會不會比較好
------
=.=??? |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |