int Display::showFeatures(IplImage *pImage1, IplImage *pImage2, float score) { int keyb = -1; if (score < _minScore) _minScore = score; _totalScore += score; _totalCount++; if (_displayingPreview) { cvDestroyWindow("Preview"); _displayingPreview = false; } if (Config::_FeatureDisplay) { // create windows if not already done if (! _displayingFeatures) { cvNamedWindow("Features", CV_WINDOW_NORMAL); cvResizeWindow("Features", NBPIXELS_WIDTH, NBPIXELS_HEIGHT*2); cvMoveWindow("Features", FEAT_POSX, FEAT_POSY); // offset from the UL corner of the screen cvNamedWindow("Quality", CV_WINDOW_AUTOSIZE); cvMoveWindow("Quality", INFO_POSX, INFO_POSY); // offset from the UL corner of the screen _displayingFeatures = true; } } updateScore(score); if (_displayingFeatures) { // update image buffer by stacking the 2 frames memcpy(_pImgFeatures->imageData, pImage1->imageData, pImage1->imageSize); memcpy(_pImgFeatures->imageData+(pImage1->imageSize), pImage2->imageData, pImage2->imageSize); cvShowImage("Features", _pImgFeatures); cvShowImage("Quality", _pImgInfo); keyb = cvWaitKey(CV_WAITKEY_TIMEOUT); if (! Config::_FeatureDisplay) { // destroy windows - asynchronous, it will be handled in event loop (cvWaitKey) cvShowImage("Features", NULL); cvShowImage("Quality", NULL); cvResizeWindow("Features", 1, 1); cvResizeWindow("Quality", 1, 1); cvDestroyWindow("Features"); cvDestroyWindow("Quality"); cvWaitKey(CV_WAITKEY_TIMEOUT); _displayingFeatures = false; } } // the opencv windows won't close until handled in event loop, so give a chance each time // a longer timeout has no effect here... int keyb2 = cvWaitKey(1); if (keyb==-1) keyb = keyb2; return keyb; }
bool _stdcall opencvProcess(LPWSTR csInputPath, LPWSTR csOutputPath) { char inputPath[SIZE] = ""; WideCharToMultiByte(950, 0, csInputPath, -1, inputPath, SIZE, NULL, NULL);//wchar_t * to char char outputPath[SIZE] = ""; WideCharToMultiByte(950, 0, csOutputPath, -1, outputPath, SIZE, NULL, NULL);//wchar_t * to char * //load image img = cvLoadImage(inputPath, 1); if(!img) return false; else { CvSize size = cvGetSize(img); int xScreen = GetSystemMetrics(SM_CXSCREEN); int yScreen = GetSystemMetrics(SM_CYSCREEN); while(size.width + 100 > xScreen || size.height + 100 > yScreen) { size.width /= 1.4; size.height /= 1.4; }//end while cvNamedWindow(windowName, 0); cvResizeWindow(windowName, size.width, size.height); cvMoveWindow(windowName, (xScreen-size.width)/2, (yScreen-size.height)/2 ); CvSize panelSize = cvSize(600, 135); cvNamedWindow(ctrlPanel, 1); cvResizeWindow(ctrlPanel, panelSize.width, panelSize.height); cvMoveWindow(ctrlPanel, (xScreen-size.width)/2, (yScreen-size.height)/2 ); cvCreateTrackbar("黑白/彩色", ctrlPanel, &isColor, 1, onTrackbar); cvCreateTrackbar("水平/垂直", ctrlPanel, &isY, 1, onTrackbar); cvCreateTrackbar("大小", ctrlPanel, &aSize, 7, onTrackbar); cvShowImage(ctrlPanel, NULL); onTrackbar(0); cvWaitKey(0); //release cvSaveImage(outputPath, dst); cvReleaseImage(&dst); cvReleaseImage(&img); cvDestroyAllWindows(); return true; }//end else return false; }//end opencvProcess
void WebCam::startLiveview() { cvNamedWindow("Scanner Window",CV_WINDOW_AUTOSIZE); cvResizeWindow("Scanner Window",640,480); liveView=true; }
void Init(int argc, char *argv[]) { capture = cvCaptureFromCAM(CV_CAP_ANY); if(!capture){ std::cout << "error starting video capture" << std::endl; exit(0); } //propose a resolution cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640); cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480); //get the actual (supported) resolution ivWidth = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); ivHeight = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT); std::cout << "camera/video resolution: " << ivWidth << "x" << ivHeight << std::endl; #ifdef FORCE_RESIZING ivWidth = RESOLUTION_X; ivHeight = RESOLUTION_Y; #endif cvNamedWindow("MOCTLD", 0); //CV_WINDOW_AUTOSIZE ); CvSize wsize = {ivWidth, ivHeight}; curImage = cvCreateImage(wsize, IPL_DEPTH_8U, 3); cvResizeWindow("MOCTLD", ivWidth, ivHeight); cvSetMouseCallback("MOCTLD", MouseHandler); }
int main(int argc, char **argv) { ros::init(argc, argv, "pototo_image_listener"); ros::NodeHandle nh; ros::Rate loop_rate(0.1); //while(ros::ok()) //{ cvNamedWindow("Boat Front",0); //0 to maintains sizes regardless of image size cvResizeWindow("Boat Front",400,250); // new width/heigh in pixels //This is used for republishing the waypoints for the obstacles ROS_INFO("getting image"); cvStartWindowThread(); image_transport::ImageTransport it(nh); //image/compressed //camera/image image_transport::Subscriber sub = it.subscribe("image", 1, imageCallback); sleep(4); fprintf(stderr,"\n I am out of the callbakc function\n"); ros::spin(); cvDestroyWindow("Boat Front"); loop_rate.sleep(); //} //while(1); return 0; }
int outputToWindow(int8_t grid[][yres]) { //Release the old frame, we dont want a memory leak! cvReleaseImage( &img ); //Create image from grid img = cvCreateImage(cvSize(xres, yres), IPL_DEPTH_8U, 3); for(int x=0; x<xres; x++){ for(int y=0; y<yres;y++){ switch(grid[x][y]) { case 0: img->imageData[3*(y*img->width+x)+0] = 0; img->imageData[3*(y*img->width+x)+1] = 0; img->imageData[3*(y*img->width+x)+2] = 0; break; case 1: img->imageData[3*(y*img->width+x)+0] = 255; img->imageData[3*(y*img->width+x)+1] = 255; img->imageData[3*(y*img->width+x)+2] = 255; break; case -1: break; default: break; } } } //Show image in the previously created window cvShowImage("OSD", img); cvResizeWindow("OSD",xres,yres); return cvWaitKey(40); }
void COpenCVMFCView::OnThresholding1() { // TODO: Add your command handler code here threImage = cvCloneImage(workImg); cvFlip(threImage); threImage0 = cvCloneImage(threImage); cvNamedWindow(threWin, 0); cvResizeWindow(threWin, 300, 320); cvCreateTrackbar( "Thresh", threWin, &Threshold, 255, onThreChange ); onThreChange(0); cvWaitKey(0); cvReleaseImage(&threImage); cvDestroyWindow(threWin); cvFlip(threImage0); m_dibFlag = imageReplace(threImage0,&workImg); m_ImageType = -1; Invalidate(); }
void ImageDisplay::display() { #ifdef IMAGE_DEBUG ifShowed = true; int width = 400; int pos[6][2] = { {0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1} }; int i = 0; for(map<string, IplImage*>::iterator it = winMap.begin(); it != winMap.end(); it++) { if(it->second == NULL) continue; // int height = double(it->second->height) / it->second->width * width; int height = 400; if(height > width) height = width; if(it->second->width > width) cvNamedWindow(it->first.c_str(), 0); else // cvNamedWindow(it->first.c_str(), 1); cvNamedWindow(it->first.c_str(), 0); cvResizeWindow(it->first.c_str(), width, height); cvShowImage(it->first.c_str(), it->second); cvMoveWindow(it->first.c_str(), pos[i % 6][0] * width, pos[i % 6][1] * 450); i++; } #endif }
ImageConverter() : it_(nh_) { image_pub_ = it_.advertise("out", 1); image_sub_ = it_.subscribe("swissranger/distance/image_raw", 1, &ImageConverter::imageCb, this); cv::namedWindow(WINDOW,0); cvResizeWindow("WINDOW",17600,14400); }
DWORD WINAPI Displayimg(LPVOID lpParamter) { SKImageDisplayerImpl::Dthread *dp = (SKImageDisplayerImpl::Dthread *)lpParamter; #ifdef RESIZE_PIC IplImage *old; IplImage *show = cvCreateImage(cvSize(SKImageDisplayer::resize_width, SKImageDisplayer::resize_height), (*(dp->p))->depth, (*(dp->p))->nChannels); old = nullptr; #endif while (1) { try { IplImage *pth = *(dp->p); #ifdef RESIZE_PIC if (old != pth || old->imageData != pth->imageData) { cvReleaseImage(&show); show = cvCreateImage(cvSize(SKImageDisplayer::resize_width, SKImageDisplayer::resize_height), (*(dp->p))->depth, (*(dp->p))->nChannels); cvResize(pth, show); } cvShowImage(dp->name.c_str(), show); cvResizeWindow(dp->name.c_str(),show->width,show->height); old = pth; #else cvShowImage(dp->name.c_str(), pth); cvResizeWindow(dp->name.c_str(),pth->width,pth->height); #endif } catch (...) { } cvWaitKey(100); dp->lock.lock(); if (dp->stop == true) break; dp->lock.unlock(); } dp->lock.unlock(); #ifdef RESIZE_PIC cvReleaseImage(&show); #endif cvDestroyWindow(dp->name.c_str()); return 0; }
void EmbedCvWindow( HWND pWnd, CString strWndName, int w, int h ) { cvNamedWindow(strWndName, 0); HWND hWnd = (HWND) cvGetWindowHandle(strWndName); HWND hParent = ::GetParent(hWnd); ::SetParent(hWnd, pWnd); // 嵌入到pWnd窗口 ::ShowWindow(hParent, SW_HIDE); ::SetWindowPos(pWnd, NULL, 0,0, w,h, SWP_NOMOVE | SWP_NOZORDER); cvResizeWindow(strWndName, w,h); }
void setupWindows(Userdata *userdata) { #if SHOW_CONTROLS //cvCreateTrackbar("kernel size", CONTROL_WINDOW, &(userdata.kernelSize), 15, trackbarCallback); cvNamedWindow(CONTROL_WINDOW "1", 0); cvResizeWindow(CONTROL_WINDOW "1", CONTROLS_WIDTH, CONTROLS_HEIGHT); cvCreateTrackbar("min 0", CONTROL_WINDOW "1", &(userdata->minScalar0), 180, trackbarCallback); cvCreateTrackbar("min 1", CONTROL_WINDOW "1", &(userdata->minScalar1), 255, trackbarCallback); cvCreateTrackbar("min 2", CONTROL_WINDOW "1", &(userdata->minScalar2), 255, trackbarCallback); cvNamedWindow(CONTROL_WINDOW "2", 0); cvResizeWindow(CONTROL_WINDOW "2", CONTROLS_WIDTH, CONTROLS_HEIGHT); cvCreateTrackbar("max 0", CONTROL_WINDOW "2", &(userdata->maxScalar0), 180, trackbarCallback); cvCreateTrackbar("max 1", CONTROL_WINDOW "2", &(userdata->maxScalar1), 255, trackbarCallback); cvCreateTrackbar("max 2", CONTROL_WINDOW "2", &(userdata->maxScalar2), 255, trackbarCallback); //cvCreateTrackbar("value", CONTROL_WINDOW, &(userdata.value), (int)sqrt(cam_height * cam_width), trackbarCallback); #endif }
void demo_regressor(char *datacfg, char *cfgfile, char *weightfile, int cam_index, const char *filename) { #ifdef OPENCV printf("Regressor Demo\n"); network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } set_batch_network(&net, 1); srand(2222222); CvCapture * cap; if(filename){ cap = cvCaptureFromFile(filename); }else{ cap = cvCaptureFromCAM(cam_index); } if(!cap) error("Couldn't connect to webcam.\n"); cvNamedWindow("Regressor", CV_WINDOW_NORMAL); cvResizeWindow("Regressor", 512, 512); float fps = 0; while(1){ struct timeval tval_before, tval_after, tval_result; gettimeofday(&tval_before, NULL); image in = get_image_from_stream(cap); image in_s = letterbox_image(in, net.w, net.h); show_image(in, "Regressor"); float *predictions = network_predict(net, in_s.data); printf("\033[2J"); printf("\033[1;1H"); printf("\nFPS:%.0f\n",fps); printf("People: %f\n", predictions[0]); free_image(in_s); free_image(in); cvWaitKey(10); gettimeofday(&tval_after, NULL); timersub(&tval_after, &tval_before, &tval_result); float curr = 1000000.f/((long int)tval_result.tv_usec); fps = .9*fps + .1*curr; } #endif }
int filterByHSV(IplImage *src, CvScalar minHSV, CvScalar maxHSV, IplImage *dst) { IplImage *tmp3d = cvCloneImage(src); cvSmooth(tmp3d, tmp3d, CV_GAUSSIAN, 13, 0, 0, 0); cvCvtColor(tmp3d, tmp3d, CV_BGR2HSV); IplImage *tmp1dH_mask = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); IplImage *tmp1dS_mask = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); IplImage *tmp1dV_mask = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); cvSplit(tmp3d, tmp1dH_mask, tmp1dS_mask, tmp1dV_mask, NULL); //printf("\rmin: %03d,%03d,%03d", (int)minHSV.val[0], (int)minHSV.val[1], (int)minHSV.val[2]); //printf("\tmax: %03d,%03d,%03d", (int)maxHSV.val[0], (int)maxHSV.val[1], (int)maxHSV.val[2]); if (minHSV.val[0] < maxHSV.val[0]) { cvInRangeS(tmp1dH_mask, cvScalar(minHSV.val[0], 0, 0), cvScalar(maxHSV.val[0], 0, 0), tmp1dH_mask); } else { IplImage *tmp1d = cvCloneImage(tmp1dH_mask); cvInRangeS(tmp1dH_mask, cvScalar(0, 0, 0), cvScalar(maxHSV.val[0], 0, 0), tmp1d); cvInRangeS(tmp1dH_mask, cvScalar(minHSV.val[0], 0, 0), cvScalar(255, 0, 0), tmp1dH_mask); cvOr(tmp1d, tmp1dH_mask, tmp1dH_mask, NULL); cvReleaseImage(&tmp1d); } cvInRangeS(tmp1dS_mask, cvScalar(minHSV.val[1], 0, 0), cvScalar(maxHSV.val[1], 0, 0), tmp1dS_mask); cvInRangeS(tmp1dV_mask, cvScalar(minHSV.val[2], 0, 0), cvScalar(maxHSV.val[2], 0, 0), tmp1dV_mask); IplImage *tmp1d_mask = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); cvSet(tmp1d_mask, cvScalarAll(255), NULL); cvAnd(tmp1d_mask, tmp1dH_mask, tmp1d_mask, NULL); cvAnd(tmp1d_mask, tmp1dS_mask, tmp1d_mask, NULL); cvAnd(tmp1d_mask, tmp1dV_mask, tmp1d_mask, NULL); cvReleaseImage(&tmp1dH_mask); cvReleaseImage(&tmp1dS_mask); cvReleaseImage(&tmp1dV_mask); cvClose(tmp1d_mask, tmp1d_mask, NULL, 2); #define CONTROLS_WIDTHA 640/2 #define CONTROLS_HEIGHTA 480/2 #if 1 cvNamedWindow(CONTROL_WINDOW "4", 0); cvResizeWindow(CONTROL_WINDOW "4", CONTROLS_WIDTHA, CONTROLS_HEIGHTA); cvShowImage(CONTROL_WINDOW "4", tmp1d_mask); #endif cvCopy2(src, dst, tmp1d_mask); cvReleaseImage(&tmp1d_mask); return 0; }
void Update_Gui_Windows() { static int first = 1; cvShowImage(eye_window, eye_image); cvShowImage(original_eye_window, original_eye_image); cvReleaseImage(&original_eye_image); cvShowImage(scene_window, scene_image); cvShowImage(ellipse_window, ellipse_image); cvResizeWindow(eye_window,RESOLUTION_WIDTH,RESOLUTION_HEIGHT); cvResizeWindow(original_eye_window,RESOLUTION_WIDTH,RESOLUTION_HEIGHT); cvResizeWindow(scene_window,RESOLUTION_WIDTH,RESOLUTION_HEIGHT); cvResizeWindow(ellipse_window,RESOLUTION_WIDTH,RESOLUTION_HEIGHT); // only OpenCV 0.9.6 has the function of cvMoveWindow(), now we are using version 0.9.5 if (first) { cvMoveWindow(eye_window, RESOLUTION_WIDTH, 0); cvMoveWindow(scene_window, 2*RESOLUTION_WIDTH, 0); cvMoveWindow(ellipse_window, RESOLUTION_WIDTH, RESOLUTION_HEIGHT); first = 0; } cvSetTrackbarPos("Edge Threshold", control_window, pupil_edge_thres); }
int main (int argc, char * const argv[]) { const char* name = "Image Window"; IplImage* img = cvLoadImage( "../../images/image1.png", 0 ); // Edge detection with Canny operation IplImage* img_e = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, img->nChannels );//canny edge detection result double lowThresh = 80; double highThresh = 200; cvCanny( img, img_e, lowThresh*7*7, highThresh*7*7, 7 ); //the center point of the ring mask int centerX=1923; int centerY=1035; //the radii of the ring mask double r1=360; //the inner circle radius double r2=540; //the outer circle radius //the size of the image int width=img->width; int height=img->height; ImageProcessing ImgProcess(centerX,centerY,height, width); ImgProcess.setEdgeImage(img_e); ImgProcess.setRingMaskAndEdgeInRing(r2,r1); ImgProcess.getEdgesStartedFrom(r1); //save the tracked points const char* savedPath="edgePointCoordinate.txt"; ImgProcess.saveContours(savedPath); //show detected edges ImgProcess.showDetectedContours(); //show original image cvNamedWindow( name, 0); cvShowImage(name, img); cvResizeWindow(name, 1000, 1000); cvWaitKey(0); // Release cvReleaseImage( &img ); cvDestroyWindow( name ); return 0; }
void CRecogDlg::ShowMatchRun() { // TODO: 在此添加控件通知处理程序代码 bool res = g_faceMngr->PicRecognize(faceImg8, FM_DO_NOT_NORM, &matchInfo); if (res) { CString msg, fn, distname; int i; strFd = matchInfo.picPath; i = strFd.ReverseFind('\\'); fn = strFd.Right(strFd.GetLength() - i - 1); strFd = strFd.Left(i+1); if (! m_bMatchStarted) return; // 检测线程是否应当结束(用户点了Exit) double score = matchInfo.dist; if (g_faceMngr->m_modelSz > 1) { score = -score; distname = "相似度(-1~1)"; } else distname = "匹配距离(0~)"; msg.Format("匹配结果:%s,%s:%f\n匹配图片路径:%s%s", ::FindName(fn), distname, score, strFd, fn); SetDlgItemText(IDC_INFO, msg); IplImage *ming = cvLoadImage(matchInfo.picPath); if (!ming) ming = cvLoadImage("noimage.bmp"); // 匹配图片读取失败 if (!ming) { ming = cvCreateImage(faceSz, 8, 1); cvSet(ming, cvScalar(255)); } CvSize msz = cvGetSize(ming); // 调整图片大小 float showscale = (float)max(msz.width, msz.height)/300; if (showscale < .3) msz *= 2; else if (showscale > 1) msz /= showscale; if (! m_bMatchStarted) return; CWnd *pWnd = GetDlgItem(IDC_MATCHIMG); // 调整窗口大小、位置 pWnd->SetWindowPos(NULL, 0,0, msz.width, msz.height, SWP_NOZORDER | SWP_NOMOVE); SetWindowPos(NULL, 0, 0, faceSz.width + 150 + msz.width, msz.height + 130, SWP_NOZORDER | SWP_NOMOVE); cvResizeWindow("match", msz.width, msz.height); cvShowImage("match", ming); cvReleaseImage(&ming); } }
void COpenCVMFCView::OnThresholding2() { // TODO: Add your command handler code here int flag=0,thre=0; threImage = cvCloneImage(workImg); cvFlip(threImage); threImage0 = cvCloneImage(threImage); cvNamedWindow(threWin, 0); cvResizeWindow(threWin, 300, 320); cvCreateTrackbar( "Thresh", threWin, &Threshold, 255, onThreChange2 ); cvShowImage( threWin, threImage ); onThreChange2(0); m_ImageType=-3; for (;;) { if (cvWaitKey(40) == 27) break; if (flag == 0) { free(m_lpBmi); m_lpBmi = CtreateMapInfo(workImg,1); flag=1; } if (Threshold != thre) { cvCopy(threImage0,workImg); cvFlip(workImg); CClientDC dc(this); StretchDIBits(dc.m_hDC, // Refresh View 0,0,workImg->width,workImg->height, 0,0,workImg->width,workImg->height, workImg->imageData,m_lpBmi,DIB_RGB_COLORS,SRCCOPY); thre = Threshold; } } cvReleaseImage(&threImage); cvReleaseImage(&threImage0); cvDestroyWindow(threWin); m_ImageType = -1; Invalidate(); }
void ImageHandler::viewImage(const char* name, int autoresize, int width, int height) { cvNamedWindow(name, autoresize); if (m_windowName == NULL) { m_windowName = new char[50]; sprintf (m_windowName, "%s", name); } cvResizeWindow(name, width, height); cvShowImage(name, m_imgSrc->curImage); }
bool _stdcall opencvProcess(LPWSTR csInputPath, LPWSTR csOutputPath) { char inputPath[SIZE] = ""; WideCharToMultiByte(950, 0, csInputPath, -1, inputPath, SIZE, NULL, NULL);//wchar_t * to char char outputPath[SIZE] = ""; WideCharToMultiByte(950, 0, csOutputPath, -1, outputPath, SIZE, NULL, NULL);//wchar_t * to char * //load image img = cvLoadImage(inputPath, -1); if(!img) return false; else { CvSize size = cvGetSize(img); int xScreen = GetSystemMetrics(SM_CXSCREEN); int yScreen = GetSystemMetrics(SM_CYSCREEN); while(size.width + 100 > xScreen || size.height + 100 > yScreen) { size.width /= 1.4; size.height /= 1.4; }//end while size.height += 90; cvNamedWindow(windowName, 0); cvResizeWindow(windowName, size.width, size.height); cvMoveWindow(windowName, (xScreen-size.width)/2, (yScreen-size.height)/2 ); int initValueW = W; int initValueH = H; cvCreateTrackbar("寬", windowName, &initValueW, img->width / 10, onTrackbarW); cvCreateTrackbar("高", windowName, &initValueH, img->height / 10, onTrackbarH); work(); cvShowImage(windowName, dst); cvWaitKey(); cvSaveImage(outputPath, dst); cvDestroyAllWindows(); cvReleaseImage(&img); cvReleaseImage(&dst); return true; }//end else return false; }//end opencvProcess
void CEnrollDlg::OnBnClickedShoot() { // TODO: 在此添加控件通知处理程序代码 if (!m_bFoundFace) return; //CFaceAlign* &al = g_faceMngr->align; #ifndef COMPILE_ALIGN_COORD CvRect rc = g_faceMngr->align->m_rcCurFace; CvSize fsz = g_webcam.GetFrameSize(); // 确保注册时脸不要太偏,大小合适 if (rc.x < fsz.width * 5 / 100 || rc.x + rc.width > fsz.width * 98 / 100 || rc.y < fsz.height * 5 / 100 || rc.y + g_faceMngr->align->m_dis*16/6 > fsz.height*95/100|| rc.width < fsz.width / 4 || rc.width > fsz.width * .7 || rc.height < fsz.height *.4 || rc.height > fsz.height*9/10) { ::AfxMessageBox("请适当调整,确保脸在画面中央,距离半米左右。"); return; } #endif CWnd *pBtn = GetDlgItem(IDC_SHOOT); RECT rc1; pBtn->GetClientRect(&rc1); pBtn->SetWindowText("拍摄下一张"); pBtn->SetWindowPos(NULL, 0,0, 70, rc1.bottom-rc1.top, SWP_NOMOVE | SWP_NOZORDER); GetDlgItem(IDC_DEL_SHOOT)->ShowWindow(SW_SHOW); GetDlgItem(IDC_ENROLL_PIC)->ShowWindow(SW_HIDE); GetDlgItem(IDC_IMPORT_MODELS)->ShowWindow(SW_HIDE); CString title; title.Format("pic %d", m_nShootNum++); cvNamedWindow(title, 0); cvResizeWindow(title, showSz.width, showSz.height); cvShowImage(title, faceImg8); IplImage *pic1 = cvCloneImage(m_frame); m_lstPic.AddTail(pic1); CvMat *face = cvCloneMat(faceImg8); m_lstFace.AddTail(face); }
HRESULT cvcamSourceFile::Start() { try { if (IsRunning()) { return NOERROR; } //Set up the window m_hr = m_pVideoWindow->put_Owner((OAHWND)m_hWnd); long flags; m_hr = m_pEvent->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0); m_hr = m_pEvent->SetNotifyFlags(0x00); m_hr = m_pEvent->CancelDefaultHandling(EC_COMPLETE); m_hr = m_pVideoWindow->get_WindowStyle(&flags); m_hr = m_pVideoWindow->put_WindowStyle(flags & (~WS_CAPTION) | WS_CHILD); m_hr = m_pVideoWindow->put_MessageDrain((OAHWND)m_hWnd); // Get the rectangle dimensions and resize the client window m_hr = m_pGraph->QueryInterface(IID_IBasicVideo,(void**)&m_pBasicVideo); long left, top, w, h; m_pBasicVideo->GetSourcePosition(&left, &top,&w,&h); m_pBasicVideo->SetDestinationPosition(0, 0, m_width?m_width:w, m_height?m_height:h); m_pVideoWindow->SetWindowPosition(0,0,m_width?m_width:w,m_height?m_height:h); const char* name = cvGetWindowName(m_hWnd); cvResizeWindow(name, m_width?m_width:w, m_height?m_height:h); // Run the graph. m_hr = m_pMediaControl->Run(); return S_OK; }//try catch(HrExeption exp) { return exp.hr; }//catch }
void ImageHandler::viewImage(const char* name, int autoresize) { //cvNamedWindow(windowName, CV_WINDOW_AUTOSIZE); cvNamedWindow(name, autoresize); if (m_windowName == NULL) { m_windowName = new char[50]; sprintf (m_windowName, "%s", name); } if (getImageSize().width < 75) { cvResizeWindow(name, 75, 75/getImageSize().width*getImageSize().height); } cvShowImage(name, m_imgSrc->curImage); }
void Histogram::show_histogram() { IplImage* histogram_img = cvCreateImage(cvSize(get_max_value()+1,m_height),8,1); cvZero(histogram_img); for(int i=0;i<m_height;i++) { int next_value = m_histo_values[i]; int j=m_height-1; while (CV_IMAGE_ELEM(histogram_img,uchar, j, next_value)==255) --j; CV_IMAGE_ELEM(histogram_img,uchar, j, next_value) = 255; } cvNamedWindow("Histogram",0); cvResizeWindow("Histogram",5*get_max_value(),5*m_height); cvShowImage("Histogram", histogram_img ); cvReleaseImage(&histogram_img); }
// Initialize window and variables void Painting::drawInit(Painting* p) { paint = p; // Save pointer to class object // Create a window namedWindow(WindowName); cvSetMouseCallback(WindowName, mouse, NULL); cvMoveWindow(WindowName, 50, 50); IplImage* image = cvCreateImage(cvSize(500,500),IPL_DEPTH_8U,3); cvZero( image ); cvRectangleR(image,cvRect(0,0,500,500),cvScalar(255,255,255), -1); cvResizeWindow(WindowName, 500, 500); mImage = image; mSelect = 0; mLeftButton = cvRect(10, 10, 100, 100); mRightButton = cvRect(490, 10, 100, 100); }
EdsError CanonCamera::startLiveview() { cvNamedWindow(windowName.c_str(),CV_WINDOW_AUTOSIZE); cvResizeWindow(windowName.c_str(),640,480); EdsError err = EDS_ERR_OK; EdsUInt32 device; err = EdsGetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0 , sizeof(device), &device ); if(err == EDS_ERR_OK) { device |= kEdsEvfOutputDevice_PC; err = EdsSetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0 , sizeof(device), &device); } liveView = true; return err; }
void show_image(type_tile *tile) { int num_components = tile->parent_img->num_components; // Allocate a float image IplImage* img = cvCreateImage(cvSize(tile->width, tile->height), IPL_DEPTH_32F, num_components); float *odata = (float *)img->imageData; int step = img->widthStep / sizeof(float); int i, j, k; float *idata = NULL; type_tile_comp *tile_comp; cuda_h_allocate_mem((void **)&idata, tile->width * tile->height * sizeof(float)); for(k = 0; k < num_components; k++) { tile_comp = &(tile->tile_comp[k]); cuda_memcpy_dth(tile_comp->img_data_d, idata, tile_comp->width * tile_comp->height * sizeof(float)); for(i = 0; i < tile_comp->width; i++) { for(j = 0; j < tile_comp->height; j++) { odata[k + i * num_components + j * step] = idata[i + j * tile_comp->width]; } } } cvNamedWindow( "ImageView", CV_WINDOW_NORMAL); if(tile->width > 1920 || tile->height > 1200) { int ratio = 1200 * ((float)tile->width / (float)tile->height); cvResizeWindow("ImageView", ratio, 1200); } cvShowImage( "ImageView", img ); cvWaitKey(0); // very important, contains event processing loop inside cvDestroyWindow( "ImageView" ); cvReleaseImage( &img ); }
int Display::showPreview(IplImage *pImage1, IplImage *pImage2) { if (Config::_FeatureDisplay) { // create window if necessary if (! _displayingPreview) { cvNamedWindow("Preview", CV_WINDOW_NORMAL); cvResizeWindow("Preview", NBPIXELS_WIDTH, NBPIXELS_HEIGHT*2); cvMoveWindow("Preview", FEAT_POSX, FEAT_POSY); // offset from the UL corner of the screen _displayingPreview = true; } // display image if (pImage1 != NULL) { memcpy(_pImgFeatures->imageData, pImage1->imageData, pImage1->imageSize); if (pImage2 != NULL) { // assume both have same size ! memcpy(_pImgFeatures->imageData+(pImage1->imageSize), pImage2->imageData, pImage2->imageSize); } } cvShowImage("Preview", _pImgFeatures); return cvWaitKey(CV_WAITKEY_TIMEOUT); } return -1; }
int Display::showOutOfSync(IplImage *pImage1, IplImage *pImage2) { CvFont font; double hScale=2; double vScale=2; int lineWidth=2; if (_displayingPreview) { cvDestroyWindow("Preview"); _displayingPreview = false; } if (Config::_FeatureDisplay && _pImgInfo != NULL) { // score is not valid updateScore(-1); cvShowImage("Quality", _pImgInfo); } if (! _displayingFeatures) { // create feature windows cvNamedWindow("Features", CV_WINDOW_NORMAL); cvResizeWindow("Features", NBPIXELS_WIDTH, NBPIXELS_HEIGHT*2); cvMoveWindow("Features", FEAT_POSX, FEAT_POSY); // offset from the UL corner of the screen _displayingFeatures = true; } // update image buffer by stacking the 2 frames if (pImage1 != NULL) { memcpy(_pImgFeatures->imageData, pImage1->imageData, pImage1->imageSize); if (pImage2 != NULL) memcpy(_pImgFeatures->imageData+(pImage1->imageSize), pImage2->imageData, pImage2->imageSize); } // define a font to write some text cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, hScale,vScale, 0, lineWidth); cvPutText(_pImgFeatures, "SYNC LOST", cvPoint(40, NBPIXELS_HEIGHT+200), &font, cvScalar(0,0,255)); cvShowImage("Features", _pImgFeatures); return cvWaitKey(CV_WAITKEY_TIMEOUT); }
void showPose( const iris::Pose_d& pose ) { // get the image cv::Mat img; iris::cimg2cv( *pose.image, img ); cv::cvtColor( img, img, CV_BGR2GRAY ); cv::cvtColor( img, img, CV_GRAY2RGB ); // get the name std::stringstream ss; ss << pose.id; std::string name = ss.str(); // render the points for( size_t i=0; i<pose.points2D.size(); i++ ) cv::circle( img, cv::Point( pose.points2D[i](0), pose.points2D[i](1) ), 5, cv::Scalar(0,255,0), -1, 8, 0 ); for( size_t i=0; i<pose.projected2D.size(); i++ ) cv::circle( img, cv::Point( pose.projected2D[i](0), pose.projected2D[i](1) ), 3, cv::Scalar(0,0,255), -1, 8, 0 ); // show the image cv::namedWindow( name, 0 ); cv::imshow( name, img ); cvResizeWindow( name.c_str(), 1024, 768 ); }