void VirtualGlasses::startCamera(){ /* std::string str="c:\\bigb.mpg"; const char * c = str.c_str(); capture =cvCreateFileCapture(c); */ capture = cvCreateCameraCapture(0); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 800 ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 600); }
void Image_Handler(FCGIContext * context, char * params) { int num = 0, width = 800, height = 600; FCGIValue val[] = { {"num", &num, FCGI_INT_T}, {"width", &width, FCGI_INT_T}, {"height", &height, FCGI_INT_T} }; if (!FCGI_ParseRequest(context, params, val, 3)) return; else if (num < 0 || num > 1) { FCGI_RejectJSON(context, "Invalid capture number"); return; } else if (width <= 0 || height <= 0) { FCGI_RejectJSON(context, "Invalid width/height"); return; } if (captureID != num) { if (captureID >= 0) { cvReleaseCapture(&capture); } capture = cvCreateCameraCapture(num); captureID = num; } cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height); static int p[] = {CV_IMWRITE_JPEG_QUALITY, 100, 0}; IplImage * frame = cvQueryFrame(capture); assert(frame != NULL); // CvMat stub; // CvMat * background = cvGetMat(frame, &stub, 0, 0); // CvMat *cv8u = cvCreateMat(frame->width, frame->height, CV_8U); // double min, max; // CvPoint a,b; // cvMinMaxLoc(background, &min, &max, &a, &b, 0); // double ccscale = 255.0/(max-min); // double ccshift = -min; //cvCvtScale(frame, cv8u, ccscale, ccshift); CvMat * jpg = cvEncodeImage(".jpg", frame, p); // Will this work? Log(LOGNOTE, "Sending image!"); FCGI_PrintRaw("Content-type: image/jpg\r\n"); FCGI_PrintRaw("Cache-Control: no-cache, no-store, must-revalidate\r\n\r\n"); //FCGI_PrintRaw("Content-Length: %d", jpg->rows*jpg->cols); FCGI_WriteBinary(jpg->data.ptr,1,jpg->rows*jpg->cols); cvReleaseMat(&jpg); cvReleaseImageHeader(&frame); }
void VideoInput::setImageSize(size_t width, size_t height) { if (_video_capture) { cvSetCaptureProperty(_video_capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(_video_capture, CV_CAP_PROP_FRAME_HEIGHT, height); std::cerr << "setImageSize: " << width << "x" << height << std::endl; } }
int main( int argc, char** argv ) { Display *dpy = XOpenDisplay (0); CvCapture* capture = cvCaptureFromCAM(0); IplImage *frame = 0; // set up the camera and windows cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, WIDTH); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, HEIGHT); if( !capture ) { fprintf(stderr,"Could not initialize capturing...\n"); return -1; } cvNamedWindow( "CamShiftDemo", 1 ); cvSetMouseCallback( "CamShiftDemo", on_mouse, 0 ); frame = cvQueryFrame( capture ); int step = frame->widthStep / sizeof (uchar); // grab frames forever for(;;) { // grab the image frame = cvQueryFrame( capture ); // try again later if we weren't successful if( !frame ) break; // mirror it cvFlip (frame, 0, 1); track_red (frame, dpy); // draw a box around the detected red region cvRectangle (frame, topleft, bottomright, cvScalar(255,255,255), 3-4*state, 8, 0); cvShowImage ("CamShiftDemo", frame); // close if they press escape char c = cvWaitKey(10); } // clean up cvReleaseCapture( &capture ); cvDestroyWindow("CamShiftDemo"); return 0; }
WebCam::WebCam(int id, int camW, int camH) { liveView=false; saveCount=1; capture = cvCaptureFromCAM(id); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, camW ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, camH); }
/*不可重入线程*/ GrabVideo::GrabVideo(QObject *parent) : QThread(parent) { /*功能编程*/ capture = cvCreateCameraCapture(0); //初始化摄像头读取视频 cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,320); cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,240); cvSetCaptureProperty(capture,CV_CAP_PROP_FPS,20); }
CCamOpenCV::CCamOpenCV(int cameraID, int width, int height) { _capture = cvCreateCameraCapture(cameraID); if (_capture && 0 < width && 0 < height) { cvSetCaptureProperty(_capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(_capture, CV_CAP_PROP_FRAME_HEIGHT, height); } }
int EdgeTest::Run() { CvCapture* capture; IplImage* frame; // Initialize the capture device capture = cvCaptureFromCAM(-1); if(!capture) { ShowError("Cannot find webcam"); return -1; } cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 700); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 700); cvSetCaptureProperty(capture, CV_CAP_PROP_CONTRAST, 0); // Create windows to display results cvNamedWindow("Capture", 1); for(;;) { // Retrive data from webcam and copy the frame to frame_mod if(!cvGrabFrame(capture)) break; frame = cvRetrieveFrame(capture); if(!frame) break; // Show image on capture screen cvFlip(frame, frame, -1); cvShowImage("Capture", frame); // Esc key if(cvWaitKey(10) >= 0) break; } cvReleaseCapture(&capture); cvDestroyWindow("EdgeTest"); cvDestroyWindow("Capture"); return 0; }
Frame::Frame(int width, int height) { capture = cvCaptureFromCAM( 0 ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, width ); cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, height ); Frame::type = Frame::VIDEO; Frame::size = cvSize(width, height); Frame::motionTrack=cvCreateImage(size,IPL_DEPTH_8U, 3); cvZero(Frame::motionTrack); }
int main(int argc, char** argv) { int width = kDefaultWidth; int height = kDefaultHeight; if (argc > 2) { int w = atoi(argv[1]); width = w ? w : width; int h = atoi(argv[2]); height = h ? h : height; } // カメラからのビデオキャプチャを初期化する CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); if (capture == NULL) { fprintf(stderr, "ERROR: Camera not found\n"); return 1; } // キャプチャサイズを設定する cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height); // ウィンドウを作成する cvNamedWindow(kWindowName, CV_WINDOW_AUTOSIZE); // フォント構造体を初期化する CvFont font; cvInitFont(&font, CV_FONT_HERSHEY_PLAIN, 1.0f, 1.0f, 0.0f, 1, CV_AA); // カメラから画像をキャプチャする while (1) { long startTick = cvGetTickCount(); IplImage* image = cvQueryFrame(capture); // カメラから一つのフレームを取り出して返す long stopTick = cvGetTickCount(); char message[kMessageSize]; snprintf(message, kMessageSize, "%.3f [ms]", (stopTick - startTick) / cvGetTickFrequency() / 1000); cvPutText(image, message, cvPoint(10, 20), &font, CV_RGB(0, 0, 0)); // 画像に文字列を描画する cvShowImage(kWindowName, image); // ウィンドウに画像を表示する int key = cvWaitKey(1); // キーが押されるまで待機する if (key == 'q') { break; } else if (key == 's') { char* filename = "capture.png"; printf("Save a capture image: %s\n", filename); //cvSaveImage(filename, image); // OpenCV 1.0 cvSaveImage(filename, image, 0); // OpenCV 2.0 } } cvReleaseCapture(&capture); cvDestroyWindow(kWindowName); return 0; }
int main(){ CvCapture* capture =0; capture = cvCaptureFromCAM(0); if(!capture){ printf("Capture failure\n"); return -1; } cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,320); cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,240); cvSetCaptureProperty(capture,CV_CAP_PROP_FPS,50); IplImage* frame=0; setwindowSettings(); //iterate through each frames of the video while(true){ frame = cvQueryFrame(capture); if(!frame) break; frame=cvCloneImage(frame); // optional load an image //frame = cvLoadImage("imagen3.png",CV_LOAD_IMAGE_COLOR ); cvSmooth(frame, frame, CV_GAUSSIAN,3,3); IplImage* imgHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3); cvCvtColor(frame, imgHSV, CV_BGR2HSV); //Change the color format from BGR to HSV IplImage* imgThresh = GetThresholdedImage(imgHSV); cvShowImage("Ball", imgThresh); cvShowImage("Video", frame); //Clean up used images cvReleaseImage(&imgHSV); cvReleaseImage(&imgThresh); cvReleaseImage(&frame); //Wait 80mS int c = cvWaitKey(80); //If 'ESC' is pressed, break the loop if((char)c==27 ) break; } cvDestroyAllWindows(); cvReleaseCapture(&capture); return 0; }
/** * Initialize images, memory, and windows */ void init() { char* msg[] = { "Blink Detection 1.0", "Copyright (c) 2009", "http://nashruddin.com", "Press 'q' to quit...", "Press 'r' to restart...", "Have fun!" }; int delay, i; capture = cvCaptureFromCAM(0); if (!capture) exit_nicely("Cannot initialize camera!"); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT); frame = cvQueryFrame(capture); if (!frame) exit_nicely("cannot query frame!"); cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.4, 0.4, 0, 1, 8); cvNamedWindow(wnd_name, 1); for (delay = 20, i = 0; i < 6; i++, delay = 20) while (delay) { frame = cvQueryFrame(capture); if (!frame) exit_nicely("cannot query frame!"); DRAW_TEXT(frame, msg[i], delay, 0); cvShowImage(wnd_name, frame); cvWaitKey(30); } storage = cvCreateMemStorage(0); if (!storage) exit_nicely("cannot allocate memory storage!"); kernel = cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_CROSS, NULL); gray = cvCreateImage(cvGetSize(frame), 8, 1); prev = cvCreateImage(cvGetSize(frame), 8, 1); diff = cvCreateImage(cvGetSize(frame), 8, 1); tpl = cvCreateImage(cvSize(TPL_WIDTH, TPL_HEIGHT), 8, 1); if (!kernel || !gray || !prev || !diff || !tpl) exit_nicely("system error."); gray->origin = frame->origin; prev->origin = frame->origin; diff->origin = frame->origin; cvNamedWindow(wnd_debug, 1); }
bool VideoDevice::OpenDev() { cp=cvCreateCameraCapture(dev); if (cp == NULL) { return false; } cvSetCaptureProperty(cp,CV_CAP_PROP_FRAME_WIDTH , 1620); cvSetCaptureProperty(cp,CV_CAP_PROP_FRAME_HEIGHT, 1240); return true; }
void Camera::setSize(int w, int h) { // TODO: The following doesn't seem to work. OpenCV build issue? // XXX: I hacked DEFAULT_V4L_WIDTH/HEIGHT in highgui/cvcap_v4l.cpp as a // temporary fix for this problem. Video4Linux definitely needs patching. cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, (double)w); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, (double)h); width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT); }
int main(int argc, char* argv[]) { CvSize size = cvSize(640,480); CvCapture* capture = cvCaptureFromCAM(0); if(!capture) { fprintf(stderr, "Error in opening the Camera.\n"); exit(1); } cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480); cvNamedWindow("Camera", CV_WINDOW_AUTOSIZE); cvNamedWindow("HSV", CV_WINDOW_AUTOSIZE); cvNamedWindow("Hue", CV_WINDOW_AUTOSIZE); cvNamedWindow("Saturation", CV_WINDOW_AUTOSIZE); cvNamedWindow("Value", CV_WINDOW_AUTOSIZE); IplImage* frame = cvQueryFrame(capture); if(!frame) exit(1); IplImage* hsv = cvCreateImage(size, IPL_DEPTH_8U, 3); IplImage* hue = cvCreateImage(size, IPL_DEPTH_8U, 1); IplImage* saturation = cvCreateImage(size, IPL_DEPTH_8U, 1); IplImage* value = cvCreateImage(size, IPL_DEPTH_8U, 1); while(1) { frame = cvQueryFrame(capture); if(!frame) { fprintf(stderr, "Failed to capture an Image.\n"); break; } cvCvtColor(frame, hsv, CV_BGR2HSV); cvSplit(hsv, hue, saturation, value, 0); cvSmooth(hue, hue, CV_GAUSSIAN,9,9,0,0); cvSmooth(saturation, saturation, CV_GAUSSIAN,9,9,0,0); cvShowImage("Camera", frame); cvShowImage("HSV", hsv); cvShowImage("Hue", hue); cvShowImage("Saturation", saturation); cvShowImage("Value", value); char c=cvWaitKey(33); if(c == 27) break; } cvDestroyAllWindows(); cvReleaseCapture(&capture); cvReleaseImage(&frame); cvReleaseImage(&hsv); }
int main() { CvCapture* capture = cvCreateCameraCapture(1); if(!capture) { printf("Camera error.\n"); return -1; } // set camera property cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, FRAMEWIDTH); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, FRAMEHEIGHT); IplImage* frame = cvQueryFrame(capture); IplImage* frame_prior = cvCreateImage( cvGetSize(frame), frame->depth, frame->nChannels); IplImage * diff12 = cvCreateImage( cvGetSize(frame), frame->depth, frame->nChannels); if(!frame) { return -1; } cvCopy(frame, frame_prior); char c; char file_name[128]; int count_frame = 0; while( 1 ) { frame = cvQueryFrame(capture); if(!frame) { return -1; } cvAbsDiff(frame, frame_prior, diff12); cvCopy(frame, frame_prior); sprintf(file_name, "%sframe_%d.bmp", SAVEIMGDIR, count_frame++ ); cvSaveImage(file_name, frame); printf("%d: %s\n", count_frame, file_name); cvShowImage("diff", diff12); c = cvWaitKey(50); if(c == 27) { break; } } cvDestroyAllWindows(); cvReleaseImage(&frame); }
bool MyCam::Init(const int iw, const int ih) { if(NULL == (m_cap = cvCreateCameraCapture(0)) || NULL ==cvQueryFrame(m_cap)){ return false; } else{ cvSetCaptureProperty(m_cap, CV_CAP_PROP_FRAME_WIDTH, iw); cvSetCaptureProperty(m_cap, CV_CAP_PROP_FRAME_HEIGHT, ih); w=iw, h=ih; return true; } }
CCameraThread::CCameraThread(CLineAdjustDlg *cLineAdj, CvCapture *pCamera, CMotorCtrl *pMotorCtrl, int index) : m_bSelfRefresh(false) , m_pTimer(0) , m_bAdjust(false) { m_cLineAdj = cLineAdj; m_pCamera = pCamera; m_iIndex = index; m_pMotorCtrl = pMotorCtrl; cvSetCaptureProperty(m_pCamera, CV_CAP_PROP_FRAME_WIDTH, FRAME_MAX_WIDTH); cvSetCaptureProperty(m_pCamera, CV_CAP_PROP_FRAME_HEIGHT, FRAME_MAX_HEIGHT); }
void USBCamera::setImageSize(int width, int height) { Capture::setImageSize(width, height); try { cvSetCaptureProperty(m_camera, CV_CAP_PROP_FRAME_WIDTH, m_frameWidth); cvSetCaptureProperty(m_camera, CV_CAP_PROP_FRAME_HEIGHT, m_frameHeight); } catch(cv::Exception & ex) { throw OpenCVException(ex.msg.c_str()); } }
/** mvCamera methods **/ mvCamera:: mvCamera (unsigned cam_number) : bin_resize ("mvCamera - resize"), bin_getFrame ("mvCamera - getFrame") { //unsigned width, height; //read_common_mv_setting ("IMG_WIDTH_COMMON", width); //read_common_mv_setting ("IMG_HEIGHT_COMMON", height); _capture = cvCreateCameraCapture (cam_number); cvSetCaptureProperty(_capture, CV_CAP_PROP_FRAME_WIDTH, 400); cvSetCaptureProperty(_capture, CV_CAP_PROP_FRAME_HEIGHT, 300); _imgResized = mvGetScratchImage_Color(); }
Webcam::Webcam(int dev, int fps) { timerId = 0; frameRate = fps; capture = cvCaptureFromCAM(dev); int width = 640; int height = 480; cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height); setFixedSize(width, height); }
OpenCVCamera::OpenCVCamera(const string &name, const uint32_t &id, const uint32_t &width, const uint32_t &height, const uint32_t &bpp) : Camera(name, id, width, height, bpp), m_capture(NULL), m_image(NULL) { m_capture = cvCaptureFromCAM(id); if (m_capture) { cvSetCaptureProperty(m_capture, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(m_capture, CV_CAP_PROP_FRAME_HEIGHT, height); } else { cerr << "proxy: Could not open camera '" << name << "' with ID: " << id << endl; } }
bool ImProc::StartVideo(int camera) { if(m_Video == 0) { m_Video=cvCaptureFromCAM(camera); // try to connect to any camera if(m_Video != 0) { cvSetCaptureProperty( m_Video, CV_CAP_PROP_FRAME_WIDTH, 640 ); cvSetCaptureProperty( m_Video, CV_CAP_PROP_FRAME_HEIGHT, 480 ); return true; } } return false; }
bool OpenCVAdapter::Init(){ Logger::Println("[OpenCVAdapter] Initialize"); myHandle=NULL; f_init=true; f_loop=false; f_start=false; string mySection="Camera"; cam_num=ApplicationProperty::ReadSetupInt(mySection,"CameraId",DEF_CAMERA_ID); width=ApplicationProperty::ReadSetupInt(mySection,"CameraWidth",DEF_CAMERA_WIDTH); height=ApplicationProperty::ReadSetupInt(mySection,"CameraHeight",DEF_CAMERA_HEIGHT); fps=ApplicationProperty::ReadSetupInt(mySection,"CameraFPS",DEF_CAMERA_FPS); xstep=ApplicationProperty::ReadSetupInt(mySection,"CameraStepX",DEF_CAMERA_STEP_X); ystep=ApplicationProperty::ReadSetupInt(mySection,"CameraStepY",DEF_CAMERA_STEP_Y); thr=ApplicationProperty::ReadSetupDouble(mySection,"CameraDevieThreshold",DEF_CAMERA_THRESHOLD); trackbarMaxValue=0xff*3+1; capture = cvCreateCameraCapture (cam_num); if(capture==NULL){ Logger::Println("[OpenCVAdapter] CreateCameraCapture Fail"); f_init=false; return false; } cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,width); cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,height); Logger::Println("[OpenCVAdapter] Launch OpenCV Thread"); myHandle = (HANDLE)_beginthreadex(NULL,0,OpenCVAdapter::Launch,this,0,NULL); if(myHandle==NULL){ f_init=false; Logger::Println("[OpenCVAdapter] CreateThread Fail"); return false; } xnum=width/xstep; ynum=height/ystep; winx=ApplicationProperty::ReadSetupInt("Graphic","WindowSizeX",640); winy=ApplicationProperty::ReadSetupInt("Graphic","WindowSizeX",480); trackbarPosition=50; trackbarPosition2=100; windowNameCap = "Capture"; windowNameThr = "Threshold"; trackbarName = "ThresholdBar"; trackbarName2 = "MinimumConnect"; fc=0; return true; }
bool CCameraCV::DoOpen () { if (m_pCvCapture!= NULL) return true; // Already opened m_pCvCapture= cvCaptureFromCAM (m_Id); if (m_pCvCapture== NULL) return false; // Try to set capture parameters although not always works cvSetCaptureProperty( m_pCvCapture, CV_CAP_PROP_FRAME_WIDTH, (double) m_Width ); cvSetCaptureProperty( m_pCvCapture, CV_CAP_PROP_FRAME_HEIGHT, (double) m_Height ); // The following line does nothing under MS Windows cvSetCaptureProperty( m_pCvCapture, CV_CAP_PROP_FPS, (double) m_FrameRate ); return true; }
IplImage* getCameraFrame(CvCapture* &camera, const char *filename = 0, int camid=0, int width=320, int height=240) { IplImage *frame = 0; int w, h; // If the camera hasn't been initialized, then open it. if (!camera) { if (!filename) { printf("Acessing the camera ...\n"); camera = cvCaptureFromCAM(camid); // Try to set the camera resolution. cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_WIDTH, width); cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_HEIGHT, height); } else { printf("Acessing the video sequence ...\n"); camera = cvCaptureFromAVI(filename); } if (!camera) { printf("Couldn't access the camera.\n"); exit(1); } // Get the first frame, to make sure the camera is initialized. frame = cvQueryFrame( camera ); //frame = cvRetrieveFrame(camera); if (frame) { w = frame->width; h = frame->height; printf("Got the camera at %dx%d resolution.\n", w, h); } //sleep(10); } // Wait until the next camera frame is ready, then grab it. frame = cvQueryFrame( camera ); //frame = cvRetrieveFrame(camera); if (!frame) { printf("Couldn't grab a camera frame.\n"); return frame; } return frame; }
void init_capture(struct ctx *ctx) { ctx->capture = cvCaptureFromCAM(0); cvSetCaptureProperty( ctx->capture, CV_CAP_PROP_FRAME_WIDTH, 640 ); cvSetCaptureProperty( ctx->capture, CV_CAP_PROP_FRAME_HEIGHT, 480 ); if (!ctx->capture) { fprintf(stderr, "Error initializing capture\n"); exit(1); } ctx->image = cvQueryFrame(ctx->capture); }
/* * Set size of frames in the video stream. */ VALUE rb_set_size(VALUE self, VALUE value) { double result = 0; CvSize size = VALUE_TO_CVSIZE(value); try { CvCapture* self_ptr = CVCAPTURE(self); cvSetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_WIDTH, size.width); result = cvSetCaptureProperty(self_ptr, CV_CAP_PROP_FRAME_HEIGHT, size.height); } catch (cv::Exception& e) { raise_cverror(e); } return DBL2NUM(result); }
//------------------------------------------------------------------------------ void OgreVideoTexture::_reinitCapture() { cvSetCaptureProperty(mCvCapture, CV_CAP_PROP_POS_MSEC, 0.0); cvGrabFrame(mCvCapture); mCurrentFrameIndex = 1; }
void Monitor::setCvCapture(CvCapture* c) { int w, h, bpp; if(c) reset(); mCvCapture = c; if(c) { cvSetCaptureProperty(mCvCapture, CV_CAP_PROP_POS_FRAMES, mCurrentFrameNumber); IplImage *im = cvQueryFrame(mCvCapture); w = im->width; h = im->height; bpp = im->nChannels; lockImages(); mCurrImage = new QImage(w, h, QImage::Format_ARGB32); convertRGB2ARGB(im, mCurrImage); releaseImages(); mInputType = AviFile; mFirstFrameNumber = 0; mLastFrameNumber = cvGetCaptureProperty(mCvCapture, CV_CAP_PROP_FRAME_COUNT) - 1; mInitialized = true; emit imageChanged(); } }