void mouseHandler(int event, int x, int y, int flags, void* param) { if(event == CV_EVENT_LBUTTONDOWN) //If left click { int** input = param; *input[0] = x; //Get the current coordinates *input[1] = y; cvDestroyAllWindows(); //And close the window } }
/*----------------------------------------------------------- Name : CloseLRFShow Argument : int id (LRF ID) Return : 0 (success) other(failed) About : Free IplImage & Windows for LRFShow Version : Ver 1.0 Date : 2014/05/25 Author : Ryodo Tanaka (Kyushu Institute of Technology) ------------------------------------------------------------*/ void CloseLRFShow(const int id) { int i; cvDestroyAllWindows(); if(id == LRF_ALL_ID) for(i=0; i<NUM_OF_LRF; i++) cvReleaseImage(&img[i]); else cvReleaseImage(&img[id]); }
void nymph_imhide(std::string window_name) { if (window_name == "") { cvDestroyAllWindows(); } else { cvDestroyWindow(window_name.data()); } }
void ctrlC_handler(const boost::system::error_code& error, int signal_number){ if (error){ std::cerr<<"signalHandler() :"<<error.message(); return; } if(signal_number == SIGTERM) std::cout<<"Recvd SIGTERM, exiting..."; if(signal_number == SIGINT) std::cout<<"Recvd SIGINT, exiting..."; cvDestroyAllWindows(); cvReleaseCapture(&capture); exit(0); }
int main() { TT_Initialize(); //setup TT cameras printf("Opening Calibration: %s\n", TT_LoadCalibration("CalibrationResult 2010-11-02 5.03pm.cal") == NPRESULT_SUCCESS ? "PASS" : "ERROR"); int cameraCount = TT_CameraCount(); CameraData_t cameras[MAX_NUM_CAMERAS]; pthread_t threads[MAX_NUM_CAMERAS]; assert(MAX_NUM_CAMERAS == cameraCount); TT_SetCameraSettings(0, NPVIDEOTYPE_PRECISION,300, 150, 15); TT_SetCameraSettings(1, NPVIDEOTYPE_PRECISION,300, 150, 15); TT_SetCameraSettings(2, NPVIDEOTYPE_PRECISION,300, 150, 15); /* 1. Change camera settings ^ 2. Allocate space for the displays */ for(int i = 0; i < cameraCount; i++){ cameras[i].i = i; cameras[i].displayImage = cvCreateImage(cvSize(W,H), IPL_DEPTH_8U, 1); } /* call the threads for display of camera data */ pthread_mutex_init(&keyMutex, NULL); for(int i = 0; i < cameraCount; i++){ if(pthread_create(&threads[i], NULL, showCameraWindow, (void*)&cameras[i])){ printf("\aThread couldn't be created!"); TT_Shutdown(); TT_FinalCleanup(); exit(0); } } printf("Press any Key to Exit!\n"); while(!_kbhit()){ int result = TT_Update(); if(result != NPRESULT_SUCCESS) Sleep(70UL); //wait for updated frame 1/sleeptime[ms] = frame-rate } for(int i = 0; i < cameraCount; i++) pthread_join(threads[i], NULL); pthread_mutex_destroy(&keyMutex); cvDestroyAllWindows(); TT_Shutdown(); TT_FinalCleanup(); return 0; }
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); }
void MoveHandler::disconnect() { logger->LogEvent("Disconnecting controller."); cvDestroyAllWindows(); this->frame = nullptr; for(int i = 0; i < this->connections; i++) { psmove_disconnect(this->controllers[i]); } psmove_tracker_free(this->tracker); }
int main() { IplImage* src = cvLoadImage("src.png", CV_LOAD_IMAGE_UNCHANGED); // c:0 0 1 9 IplImage* gaussian_one_nine = cvCreateImage( cvGetSize(src), src->depth, src->nChannels ); // d:0 0 9 1 IplImage* gaussian_nine_one = cvCreateImage( cvGetSize(src), src->depth, src->nChannels ); // e:0 0 1 9 --> 0 0 9 1 IplImage* gaussian_twice = cvCreateImage( cvGetSize(src), src->depth, src->nChannels ); // f: IplImage* gaussian_fpart = cvCreateImage( cvGetSize(src), src->depth, src->nChannels ); printf("0 0 1 9\n"); cvSmooth(src, gaussian_one_nine, CV_GAUSSIAN, 0, 0, 1, 9); printf("\n0 0 9 1\n"); cvSmooth(src, gaussian_nine_one, CV_GAUSSIAN, 0, 0, 9, 1); printf("\n0 0 1 9 --> 0 0 9 1\n"); // 7 55 1 9 cvSmooth(src, gaussian_twice, CV_GAUSSIAN, 0, 0, 1, 9); // 55 7 9 1 cvSmooth(gaussian_twice, gaussian_twice, CV_GAUSSIAN, 0, 0, 9, 1); // 55 55 9 9 cvSmooth(src, gaussian_fpart, CV_GAUSSIAN, 0, 0, 9, 9); //cvSmooth(gaussian_fpart, gaussian_fpart, CV_GAUSSIAN, 9, 9, 0, 0); double dMSE = 0, dPSNR = 0; calculateGrayImgsPSNR(gaussian_twice, gaussian_fpart, dMSE, dPSNR); printf("MSE: %f\tPSNR: %f\n", dMSE, dPSNR); cvShowImage("src", src); cvShowImage("one_nine", gaussian_one_nine); cvSaveImage( "0019.png", gaussian_one_nine ); cvShowImage("nine_one", gaussian_nine_one); cvSaveImage("0091.png", gaussian_nine_one); cvShowImage("twice", gaussian_twice); cvSaveImage("twice.png", gaussian_twice); cvShowImage("fpart", gaussian_fpart); cvSaveImage( "fpart.png", gaussian_fpart ); cvWaitKey(0); cvDestroyAllWindows(); cvReleaseImage(&src); return 0; }
void the_project::project_clear() { cout << "Finished...\n"; cvDestroyAllWindows(); //cvReleaseImage(&get_in); cvReleaseImage(&get_change); cvReleaseImage(&get_binary); cvReleaseImage(&get_path); cvReleaseVideoWriter(&wr1); cvReleaseVideoWriter(&wr2); cvReleaseCapture(&for_video); cvReleaseCapture(&for_cam); }
int _tmain(int argc, _TCHAR* argv[]) { CCharRecognition myCC; #ifdef TrainML for(int i=1;i<214;i++) #else for(int i=1; i<=121; i++) #endif { // 产生文件名 char fn[1024]; #ifdef TrainML sprintf(fn, ".//sample//b (%d).jpg", i); #else sprintf(fn, ".//train//T (%d).jpg", i); #endif // 读取图片 IplImage* gray = cvLoadImage(fn);//, CV_LOAD_IMAGE_GRAYSCALE); IplImage* gray2 = cvLoadImage(fn);//, CV_LOAD_IMAGE_GRAYSCALE); cvShowImage("1", gray2); cvWaitKey(10); #ifdef TrainML myCC.GetSamples(gray); #else string ss=myCC.RecogniteCharImage(gray); std::cout<<ss<<std::endl; #endif char ch=cvWaitKey(0); #ifndef TrainML static int right=0; static int sum=0; if(ch=='a') right++; sum++; std::cout<<'\t'<<right<<'\\'<<sum; #endif std::cout<<std::endl; cvReleaseImage(&gray); cvReleaseImage(&gray2); } cvDestroyAllWindows(); system("pause"); return 0; }
void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh) { network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } detection_layer l = net.layers[net.n-1]; set_batch_network(&net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; int j; float nms=.5; box *boxes = calloc(l.side*l.side*l.n, sizeof(box)); float **probs = calloc(l.side*l.side*l.n, sizeof(float *)); for(j = 0; j < l.side*l.side*l.n; ++j) probs[j] = calloc(l.classes, sizeof(float *)); while(1){ if(filename){ strncpy(input, filename, 256); } else { printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input,0,0); image sized = resize_image(im, net.w, net.h); float *X = sized.data; time=clock(); float *predictions = network_predict(net, X); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, probs, boxes, 0); if (nms) do_nms_sort(boxes, probs, l.side*l.side*l.n, l.classes, nms); //draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, voc_labels, 20); draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, 0, 20); show_image(im, "predictions"); save_image(im, "predictions"); show_image(sized, "resized"); free_image(im); free_image(sized); #ifdef OPENCV cvWaitKey(0); cvDestroyAllWindows(); #endif if (filename) break; } }
void viewImage(IplImage* img) { if (img->depth == IPL_DEPTH_16U) { cvConvertImage(img,showImage); cvShowImage("Image", showImage); } else { cvShowImage("Image",img); } cvWaitKey(); cvDestroyAllWindows(); }
int main(int argc, char* argv[]) { cvNamedWindow("Original",CV_WINDOW_AUTOSIZE); cvNamedWindow("Binaria",CV_WINDOW_AUTOSIZE); cvNamedWindow("Histograma",CV_WINDOW_AUTOSIZE); imatge = cvLoadImage("C:\\EUPMT\\Projects\\OpenCV_Contours\\exemple03.jpg", 0); IplImage* binaria = cvCreateImage(cvGetSize(imatge), 8, 1); imgHistogram = 0; int hsize[] = {bins}; float max_value = 0, min_value = 0; float xranges[] = { 0, 256 }; float* ranges[] = { xranges }; hist = cvCreateHist( 1, hsize, CV_HIST_ARRAY, ranges,1); cvCalcHist( &imatge, hist, 0, NULL); cvGetMinMaxHistValue( hist, &min_value, &max_value); dibuixarHistograma(max_value); int llindar = llindar_gaussian(imatge, hist); int step =imatge->widthStep; int canals = imatge->nChannels; uchar* imgData = (uchar*) imatge->imageData; uchar* imgDataBinaria = (uchar*) binaria->imageData; for( int i = 0; i < imatge->height; i++) for( int j = 0; j < imatge->width; j++) { if((imgData[i*step+j*canals]) > llindar) { imgDataBinaria[i*binaria->widthStep+j*binaria->nChannels]=0; } else { imgDataBinaria[i*binaria->widthStep+j*binaria->nChannels]=255; } } cvShowImage("Original", imatge); cvShowImage("Histograma", imgHistogram); cvShowImage("Binaria", binaria); cvWaitKey(0); cvDestroyAllWindows(); return 0; }
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
int main(int argc, char* argv[]) { int task_id = atoi(argv[1]); int no_jobs = atoi(argv[2]); movie_id = atoi(argv[3]); initialize(); if(capture == NULL) { printf("capture is null movie_id %d\n", movie_id); return -1; } img = cvQueryFrame(capture); thresh = cvCreateImage(cvGetSize(img),8,1); int tmp = 0;//rt_attach_task_to_mod(task_id); printf("res: %d task %d attached to the module!\n", tmp, task_id); int i = 0; while(i<no_jobs) { i++; gettimeofday(&tv_start, (struct timezone*)0); //get image from camera feed img = cvQueryFrame(capture); //thresh = cvCreateImage(cvGetSize(img),8,1); //Thresholding the image cvInRangeS(img,cvScalar(b1,g1,r1,0),cvScalar(b2,g2,r2,0),thresh); //Showing the images cvShowImage("Original",img); cvShowImage("Thresholded",thresh); gettimeofday(&tv_end, (struct timezone*)0); printf("task <%d>job %d Elapsed time: %f imageID %d\n", task_id, i, ((tv_end.tv_sec - tv_start.tv_sec)*1000000 + (tv_end.tv_usec - tv_start.tv_usec))/1000000.0, img->ID); // //rt_task_finish_job(task_id); //Escape Sequence // char c=cvWaitKey(33); // if(c==27) // break; } //Cleanup cvReleaseImage(&img); cvReleaseImage(&thresh); cvDestroyAllWindows(); rt_detach_task(task_id); printf("task %d finished!\n", task_id); }
void Window::show(void) { char tool; while(1) { tool = cvWaitKey(10); cvShowImage("2011-B007",this->image); if( tool == 27 || tool == 'q' || tool == 'Q' ) // 'ESC', q o Q break; } cvReleaseImage( &this->image ); cvDestroyAllWindows();//Destruimos todas las ventanas }
void test_writing(char *cfgfile, char *weightfile, char *filename) { network * net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(net, weightfile); } set_batch_network(net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; while(1){ if(filename){ strncpy(input, filename, 256); }else{ printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input, 0, 0); resize_network(net, im.w, im.h); printf("%d %d %d\n", im.h, im.w, im.c); float *X = im.data; time=clock(); network_predict(net, X); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); image pred = get_network_image(net); image upsampled = resize_image(pred, im.w, im.h); image thresh = threshold_image(upsampled, .5); pred = thresh; show_image(pred, "prediction"); show_image(im, "orig"); #ifdef OPENCV cvWaitKey(0); cvDestroyAllWindows(); #endif free_image(upsampled); free_image(thresh); free_image(im); if (filename) break; } }
void main() { // connect camera capture = cvCaptureFromCAM(CV_CAP_ANY); if(!capture) { std::cout << "can not connect any camera" << std::endl; exit(0); } cvNamedWindow("tracking information window"); resizeImage = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 3); grayImage = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 1); resultImage = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 3); logging = new windage::Logger(&std::cout); logging->updateTickCount(); // create tracker tracker = CreateTracker(); #if USE_TEMPLATE_IMAEG IplImage* sampleImage = cvLoadImage(TEMPLATE_IMAGE, 0); double threahold = tracker->GetDetector()->GetThreshold(); tracker->GetDetector()->SetThreshold(30.0); tracker->AttatchReferenceImage(sampleImage); tracker->TrainingReference(SCALE_FACTOR, SCALE_STEP); tracker->GetDetector()->SetThreshold(threahold); #endif // initialize rendering engine using GLUT renderer = new OpenGLRenderer(); renderer->Initialize(RENDERING_WIDTH, RENDERING_HEIGHT, "windage Camera Tracjectory"); renderer->SetCameraSize(WIDTH, HEIGHT); glutDisplayFunc(display); glutIdleFunc(idle); glutKeyboardFunc(keyboard); glutMouseFunc(mouseClick); glutMotionFunc(mouseMove); glutMainLoop(); cvReleaseCapture(&capture); cvDestroyAllWindows(); }
int main() { CvCapture* capture =0; capture = cvCaptureFromCAM(0); if(!capture) { printf("Capture failure\n"); return -1; } IplImage* frame=0; cvNamedWindow("Video"); cvNamedWindow("Ball"); //iterate through each frames of the video while(true) { frame = cvQueryFrame(capture); if(!frame) break; frame=cvCloneImage(frame); cvSmooth(frame, frame, CV_GAUSSIAN,3,3); //smooth the original image using Gaussian kernel 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); cvSmooth(imgThresh, imgThresh, CV_GAUSSIAN,3,3); //smooth the binary image using Gaussian kernel cvShowImage("Ball", imgThresh); cvShowImage("Video", frame); //Clean up used images cvReleaseImage(&imgHSV); cvReleaseImage(&imgThresh); cvReleaseImage(&frame); //Wait 50mS int c = cvWaitKey(10); //If 'ESC' is pressed, break the loop if((char)c==27 ) break; } cvDestroyAllWindows() ; cvReleaseCapture(&capture); return 0; }
int main(int argc, char** argv) { if(argc != 1) { // Robot selection if(atoi(argv[1]) == 1) {nao = "1";} if(atoi(argv[1]) == 2) {nao = "2";} ros::init(argc, argv,"GoClose" + nao); ros::NodeHandle nh; ros::NodeHandle pnh("~"); // Robot parameters std::string NAO_IP; int NAO_PORT; pnh.param("NAO_IP",NAO_IP,std::string("127.0.0.1")); pnh.param("NAO_PORT",NAO_PORT,int(9559)); // HSV parameters pnh.param("H_MIN",H_MIN,int(0)); pnh.param("H_MAX",H_MAX,int(0)); pnh.param("S_MIN",S_MIN,int(0)); pnh.param("S_MAX",S_MAX,int(0)); pnh.param("V_MIN",V_MIN,int(0)); pnh.param("V_MAX",V_MAX,int(0)); hsv_min = cvScalar(H_MIN,S_MIN,V_MIN,0); hsv_max = cvScalar(H_MAX,S_MAX,V_MAX,0); // Sonar subscriber ros::Subscriber sonar_sub = nh.subscribe("/sonar" + nao,1000,receive_sonar); // Walker publisher cmd_pub = nh.advertise<geometry_msgs::Twist>("/cmd_vel" + nao,100); // Launch Server GoClose server(ros::this_node::getName(),NAO_IP,NAO_PORT); ros::spin(); cvDestroyAllWindows(); } else { puts("Error, not enough arguments"); } return 0; }
void mouseDetector::onMouse(int event, int x, int y, int, void*){ //namedWindow("test", CV_WINDOW_AUTOSIZE); //imshow("test", mouseDetector::workingMat); Point pt; if (event == CV_EVENT_LBUTTONDOWN){ pt.x = x; pt.y = y; cout << "Point" << TOTAL_POINTS + 1 - n << "(" << x << "," << y << ")" << endl; mouseDetector::capturePoint.push_back(pt); mouseDetector::n--; //circle(mouseDetector::workingMat,pt,2,Scalar(0,0,255), 5); if(n==0){ cvDestroyAllWindows(); } } }
int _tmain(int argc, _TCHAR* argv[]) { int i, j; IplImage *inputImage = cvLoadImage("lena.bmp",CV_LOAD_IMAGE_GRAYSCALE); IplImage *gammaCorrection = cvCreateImage(cvGetSize(inputImage), inputImage->depth, inputImage->nChannels); CvScalar pixelValue, temp; for(i=0; i<inputImage->height;i++) { for(j=0; j<inputImage->width;j++) { pixelValue = cvGet2D(inputImage, i, j); temp.val[0] = pow(pixelValue.val[0], 1/GAMMA_CONSTANT); if(temp.val[0] < 0) { temp.val[0] = 0; cvSet2D(gammaCorrection,i,j,temp); } else if(temp.val[0] > 255) { temp.val[0]=255; cvSet2D(gammaCorrection,i,j,temp); } else { cvSet2D(gammaCorrection,i,j,temp); } } } cvNamedWindow("input",CV_WINDOW_AUTOSIZE); cvNamedWindow("Gamma",CV_WINDOW_AUTOSIZE); cvShowImage("input",inputImage); cvShowImage("Gamma",gammaCorrection); cvWaitKey(); cvDestroyAllWindows(); cvReleaseImage(&inputImage); cvReleaseImage(&gammaCorrection); return 0; }
int main(int argc,char ** argv) { IplImage* originalframe=0; Create_Windows_and_Trackbars(); while(1) { originalframe=cvLoadImage(argv[1]); IplImage* HSVImage=cvCreateImage((cvGetSize(originalframe)), IPL_DEPTH_8U,3); cvSmooth(originalframe,originalframe,CV_GAUSSIAN,9,9); cvCvtColor(originalframe,HSVImage,CV_BGR2HSV); IplImage *BinaryImage=HsvToBinaryConverter(HSVImage); cvShowImage("Processed",BinaryImage); cvShowImage("Original",originalframe); cvReleaseImage(&originalframe); cvReleaseImage(&BinaryImage); cvReleaseImage(&HSVImage); char c=cvWaitKey(10); if(c==27) break; } cvDestroyAllWindows(); // cvReleaseCapture(&cam); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { int mode = 0; int modeChild = 0; int camera = 0; //mode = 0; // dump //mode = 1; // save mode = 2; // combine //mode = 3; // play //modeChild = 0; modeChild = 1; camera = 0; // video //camera = 1; // camera if (mode == 0) { if (camera == 0) { if (modeChild == 0) { dumpHandleStreamVideo(); } else { dumpHandleStreamVideoOnTrackBar(); } } else { dumpHandleStreamCamera(); } } else if (mode == 1) { if (camera != 0) { saveHandleStreamCamera(); } else { saveHandleStreamVideo(); } } else if (mode == 2) { sampleImageUtileCombineImage(); } else if (mode == 3) { if (camera != 0) { playHandleStreamCamera(); } else { playHandleStreamVideo(); } } cvDestroyAllWindows(); return 0; }
/** * @brief The program entry point. */ int main() { CvCapture* capture = 0; capture = cvCaptureFromCAM(1); if (!capture) { printf("Capture failure\n"); return -1; } IplImage* frame = 0; setwindowSettings(); //iterate through each frames of the video while (true) { frame = cvQueryFrame(capture); if (!frame) break; frame = cvCloneImage(frame); 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; }
int main(){ CvCapture* ambil =0; ambil = cvCaptureFromCAM(0); if(!ambil){ printf("Capture failure\n"); return -1; } IplImage* frame=0; cvNamedWindow("Video"); cvNamedWindow("Deteksi Warna"); //iterasi while(true){ frame = cvQueryFrame(ambil); if(!frame) break; frame=cvCloneImage(frame); cvSmooth(frame, frame, CV_GAUSSIAN,3,3); //menghasilkan penghalusan gambar dengan metode Gaussian kernel IplImage* imgHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3); cvCvtColor(frame, imgHSV, CV_BGR2HSV); //Merubah format warna from RGB to HSV IplImage* imgThresh = GetThresholdedImage(imgHSV); cvSmooth(imgThresh, imgThresh, CV_GAUSSIAN,3,3); cvShowImage("Deteksi Warna", imgThresh); cvShowImage("Video", frame); cvReleaseImage(&imgHSV); cvReleaseImage(&imgThresh); cvReleaseImage(&frame); int c = cvWaitKey(10); //If 'ESC' is pressed, break the loop if((char)c==27 ) break; } cvDestroyAllWindows() ; cvReleaseCapture(&ambil); return 0; }
int main (int argc, char *argv[]) { CvHMM *models; char *win = "hand"; int num, count=0, curr=1; ptseq seq; parse_args(argc,argv); seq = ptseq_init(); for (;;) { IplImage *depth, *tmp, *body, *hand; CvSeq *cnt; CvPoint cent; int z, p, k; depth = freenect_sync_get_depth_cv(0); body = body_detection(depth); hand = hand_detection(body, &z); if (!get_hand_contour_basic(hand, &cnt, ¢)) continue; if ((p = basic_posture_classification(cnt)) == -1) continue; if (cvhmm_get_gesture_sequence(p, cent, &seq)) { ptseq_draw(seq, 0); if ((k = cvWaitKey(0)) == 's') { save_sequence(outfile, seq, N); break; } seq = ptseq_reset(seq); } hand = draw_depth_hand(cnt, p); cvShowImage("hand", hand); if ((k = cvWaitKey(T)) == 'q') break; } freenect_sync_stop(); cvDestroyAllWindows(); return 0; }
int main(int argc, char* argv[]) { IplImage* image=0, *dst=0; char filename[] = "Image0.jpg"; image = cvLoadImage(filename, 1); printf("[i] image: %s\n", filename); assert( image != 0 ); cvNamedWindow( "image"); cvShowImage( "image", image ); cvWaitKey(0); cvReleaseImage(& image); cvReleaseImage(&dst); // удаляем окна cvDestroyAllWindows(); return 0; }
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