当前位置: 首页>>代码示例>>C++>>正文


C++ cvGetTickCount函数代码示例

本文整理汇总了C++中cvGetTickCount函数的典型用法代码示例。如果您正苦于以下问题:C++ cvGetTickCount函数的具体用法?C++ cvGetTickCount怎么用?C++ cvGetTickCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cvGetTickCount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cvCreateMemStorage

void QOpenCvImageBox::old_detect_and_draw_faces( IplImage* img, CvMemStorage* storage, CvHaarClassifierCascade* cascade )
{
    // Create two points to represent the face locations
    CvPoint pt1, pt2;

    IplImage *gray, *small_img;
    int i;

    if( cascade )
    {
        storage = cvCreateMemStorage(0);

        gray = cvCreateImage( cvSize(img->width,img->height), 8, 1 );
        small_img = cvCreateImage( cvSize( cvRound (img->width/od_image_scale), cvRound (img->height/od_image_scale)), 8, 1 );

        cvCvtColor( img, gray, CV_RGB2GRAY );
        cvResize( gray, small_img, CV_INTER_LINEAR );
        cvEqualizeHist( small_img, small_img );
        cvClearMemStorage( storage );

        double t = (double)cvGetTickCount();
        CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage,
                                            1.1, 2, 0
                                            //|CV_HAAR_FIND_BIGGEST_OBJECT
                                            //|CV_HAAR_DO_ROUGH_SEARCH
                                            |CV_HAAR_DO_CANNY_PRUNING
                                            //|CV_HAAR_SCALE_IMAGE
                                            ,
                                            cvSize(30, 30) );
        t = (double)cvGetTickCount() - t;

        printf( "detection time = %gms\n", t/((double)cvGetTickFrequency()*1000.) );

        cvReleaseImage( &gray );
        cvReleaseImage( &small_img );

        // Loop the number of faces found.
        printf("Detected %d faces!\n", faces->total);

        for( i = 0; i < (faces ? faces->total : 0); i++ )
        {
            // Create a new rectangle for drawing the face
            CvRect* r = (CvRect*)cvGetSeqElem( faces, i );

            if(r) {
                // Find the dimensions of the face,and scale it if necessary
                pt1.x = r->x*od_image_scale;
                pt2.x = (r->x+r->width)*od_image_scale;
                pt1.y = r->y*od_image_scale;
                pt2.y = (r->y+r->height)*od_image_scale;

                // Draw the rectangle in the input image
                cvRectangle( img, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
            }
        }

        cvClearSeq(faces);
        cvReleaseMemStorage(&storage);
    }
}
开发者ID:demetrio812,项目名称:QtOpenCV,代码行数:60,代码来源:qopencvimagebox.cpp

示例2: main

/**
* This is an example on how to call the thinning function above.
*/
int main()
{
	cv::Mat src = cv::imread("../test_image.png");

	if (src.empty())
		return -1;

	cv::Mat bw;
	cv::cvtColor(src, bw, CV_BGR2GRAY);
	cv::threshold(bw, bw, 10, 255, CV_THRESH_BINARY);

	const int N = 30;
	int64 time = 0;
	for (int i = 0; i < N; ++i)
	{
		cv::Mat bb = i < N - 1 ? bw.clone() : bw;
		int64 t = cvGetTickCount();
		thinning(bb, false);
		time += (cvGetTickCount() - t);
	}
	
	printf("%f", time / cvGetTickFrequency() / N);

	//thinning(bw);
	cv::imshow("src", src);
	cv::imshow("dst", bw);
	cv::waitKey(0);

	return 0;
}
开发者ID:romanzubarev,项目名称:homework1,代码行数:33,代码来源:OptimizationCourseHomework1.cpp

示例3: detect

// Function to detect objects
static void detect(image_session_t *mySession)
{
double t = 0;
uint16_t current_category;
LinkedCascade *cascade;

	for(current_category = 0; current_category < num_image_categories; current_category++)
	{
		if(CI_DEBUG_LEVEL >= PERF_DEBUG_LEVEL) t = cvGetTickCount();
		// Find whether the cascade is loaded, to find the objects. If yes, then:
		if(mySession->detected[current_category].category->cascade_array)
		{
			cascade = getFreeCascade(mySession->detected[current_category].category);
			// There can be more than one object in an image. So create a growable sequence of detected objects.
			// Detect the objects and store them in the sequence
#ifdef HAVE_OPENCV
			mySession->detected[current_category].detected = cvHaarDetectObjects( mySession->rightImage, cascade->cascade, mySession->dstorage,
								1.1, 1, 0, cvSize(0, 0) );
#endif
#ifdef HAVE_OPENCV_22X
			mySession->detected[current_category].detected = cvHaarDetectObjects( mySession->rightImage, cascade->cascade, mySession->dstorage,
								1.1, 1, 0, cvSize(0, 0), cvSize(mySession->rightImage->width, mySession->rightImage->height));
#endif
			unBusyCascade(mySession->detected[current_category].category, cascade);
		}
		if(CI_DEBUG_LEVEL >= PERF_DEBUG_LEVEL)
		{
			t = cvGetTickCount() - t;
			t = t / ((double)cvGetTickFrequency() * 1000.);
			ci_debug_printf(8, "srv_classify_image: File: %s Object: %s (%d) Detection took: %gms.\n", (rindex(mySession->fname, '/'))+1, mySession->detected[current_category].category->name, mySession->detected[current_category].detected->total, t);
		}
	}
}
开发者ID:cloudmeapp,项目名称:C-ICAP-Classify,代码行数:34,代码来源:srv_classify_image.c

示例4: detect_and_draw

void detect_and_draw( IplImage* img) {
    static CvScalar colors[] = {
        {{0,0,255}},
        {{0,128,255}},
        {{0,255,255}},
        {{0,255,0}},
        {{255,128,0}},
        {{255,255,0}},
        {{255,0,0}},
        {{255,0,255}}
    };

    double scale = 1.3;
    IplImage* gray = cvCreateImage( cvSize(img->width,img->height), 8, 1 );
    IplImage* small_img = cvCreateImage( cvSize( cvRound (img->width/scale),
                                                 cvRound (img->height/scale)),
                                         8, 1 );
    int i;

    IplImage* onlyhaart = cvCreateImage(cvGetSize(img), img->depth, img->nChannels);
    cvCopy(img, onlyhaart);

    cvCvtColor( img, gray, CV_BGR2GRAY );
    cvResize( gray, small_img, CV_INTER_LINEAR );
    cvEqualizeHist( small_img, small_img );
    cvClearMemStorage( storageHaart );

    if(cascade) {
        double t = (double)cvGetTickCount();
        CvSeq* faces = cvHaarDetectObjects(small_img, cascade, storageHaart,
                                           1.1, 2, 0/*CV_HAAR_DO_CANNY_PRUNING*/,
                                           cvSize(30, 30) );
        t = (double)cvGetTickCount() - t;
        for(i = 0; i < (faces ? faces->total : 0); i++ ) {
            CvRect* r = (CvRect*)cvGetSeqElem( faces, i );

            CvRect rect = cvRect(r->x, r->y, r->width, r->height);

            if ((rect.height < (img->height + 1)) & (rect.width < (img->width + 1))) {
                printf( "detection time = %gms\n", t/((double)cvGetTickFrequency()*100.) );
                CvPoint center;
                int radius;
                center.x = cvRound((rect.x + rect.width*0.5)*scale);
                center.y = cvRound((rect.y + rect.height*0.5)*scale);
                radius = cvRound((rect.width + rect.height)*0.25*scale);
                cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
            }
            CvPoint center;
            int radius;
            center.x = cvRound((rect.x + rect.width*0.5)*scale);
            center.y = cvRound((rect.y + rect.height*0.5)*scale);
            radius = cvRound((rect.width + rect.height)*0.25*scale);
            cvCircle( onlyhaart, center, radius, colors[i%8], 3, 8, 0 );
        }
    }
    cvShowImage( "Detecta", img );
    cvShowImage( "onlyhaart", onlyhaart);
    cvReleaseImage( &gray );
    cvReleaseImage( &small_img );
}
开发者ID:mrcportillo,项目名称:Guda,代码行数:60,代码来源:haartMain.cpp

示例5: small_img

void CFaceDetect::detectAndDisplay(Mat& img, RECT* detectBox) 
{
	double scale=1.2;
	Mat small_img(cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1);
	Mat gray(cvRound (img.rows/scale),cvRound(img.cols/scale),8,1);
	cvtColor(img, gray, CV_BGR2GRAY);
	resize(gray, small_img, small_img.size(), 0, 0, INTER_LINEAR);
	equalizeHist(small_img,small_img); //Ö±·½Í¼¾ùºâ

	//Detect the biggest face
	double t = (double)cvGetTickCount(); 
	std::vector<cv::Rect> faces; 
	cascade.detectMultiScale(small_img, faces, 1.1, 2, CV_HAAR_FIND_BIGGEST_OBJECT, cvSize(30, 30)); 
	t = (double)cvGetTickCount() - t; 
	printf( "detection time = %gms\n", t/((double)cvGetTickFrequency()*1000.) );

	//found objects and draw boxes around them 
	if(faces.size() == 1)
	{
		(*detectBox).left = faces[0].x * scale;
		(*detectBox).right = (faces[0].x + faces[0].width) * scale;		
		(*detectBox).top = faces[0].y * scale + 10;
		(*detectBox).bottom = (faces[0].y + faces[0].height) * scale + 10;
		rectangle(img, cvPoint((*detectBox).left,(*detectBox).top), cvPoint((*detectBox).right,(*detectBox).bottom), Scalar( 255, 0, 0 ));
	}
	else
	{
		printf("Fail to detect faces.\n");
	}
	return;
}
开发者ID:fishwsr,项目名称:FaceAlign,代码行数:31,代码来源:FaceDetect.cpp

示例6: if

/**
* @param    trackalg-   input and output    the track algorithm,
                        will record some information for every frame
* @param    iImg    - input     input image
* @param    iShape  - input     the current tracked shape
* @return   bool    whether the tracked shape is acceptable?
*/
bool CRecognitionAlgs::EvaluateFaceTrackedByProbabilityImage(
    CTrackingAlgs* trackalg,
    const Mat& iImg,
    const VO_Shape& iShape,
    Size smallSize,
    Size bigSize)
{
    double t = (double)cvGetTickCount();

    Rect rect = iShape.GetShapeBoundRect();

    trackalg->SetConfiguration( CTrackingAlgs::CAMSHIFT,
                                CTrackingAlgs::PROBABILITYIMAGE);
    trackalg->Tracking( rect,
                        iImg,
                        smallSize,
                        bigSize );

    bool res = false;
    if( !trackalg->IsObjectTracked() )
        res = false;
    else if ( ((double)rect.height/(double)rect.width <= 0.75)
        || ((double)rect.height/(double)rect.width >= 2.5) )
        res = false;
    else
        res = true;

    t = ((double)cvGetTickCount() -  t )
        / (cvGetTickFrequency()*1000.);
    cout << "Camshift Tracking time cost: " << t << "millisec" << endl;

    return res;
}
开发者ID:HVisionSensing,项目名称:mc-vosm,代码行数:40,代码来源:VO_RecognitionAlgs.cpp

示例7: detectInImage

// Perform a detection on the input image, using the given Haar Cascade.
// Returns a rectangle for each detected region in the given image.
CvSeq* detectInImage(IplImage *imageProcessed, CvHaarClassifierCascade* cascade)
{
	// possibly convert to gray and equalize to improve detection
	//convert to gray
	IplImage * greyImg = convertImageToGreyscale(imageProcessed);

	const CvSize minFeatureSize = cvSize(100/pyrDownScale, 100/pyrDownScale);
	const int flags = CV_HAAR_DO_ROUGH_SEARCH | CV_HAAR_DO_CANNY_PRUNING;
	float search_scale_factor =  1.5f ;

	double t;
	unsigned int ms = 0;

	cvClearMemStorage( bodyStorage );

	// down-scale the image to get performance boost
	IplImage * small_img = cvCreateImage( 
		cvSize(greyImg->width/pyrDownScale,greyImg->height/pyrDownScale),
		IPL_DEPTH_8U, greyImg->nChannels 
		);
	cvPyrDown(greyImg, small_img, CV_GAUSSIAN_5x5);
	
	// Detect all the faces in the greyscale image.
	t = (double)cvGetTickCount();
	rects = cvHaarDetectObjects( small_img, cascade, bodyStorage,
				search_scale_factor, 2, flags, minFeatureSize);
	t = (double)cvGetTickCount() - t;
	ms = cvRound( t / ((double)cvGetTickFrequency() * 1000.0) );
	printf("Detection took %d ms and found %d objects\n", ms, rects->total);

	cvReleaseImage(&small_img);
	cvReleaseImage(&greyImg);

	return rects;
}
开发者ID:Onumis,项目名称:Kinect-and-Bullet,代码行数:37,代码来源:imageUtils.cpp

示例8: getRightSize

static void getRightSize(image_session_t *mySession)
{
double t;
int maxDim = mySession->origImage->width > mySession->origImage->height ? mySession->origImage->width : mySession->origImage->height;

	// Create a new image based on the input image
	if(CI_DEBUG_LEVEL >= PERF_DEBUG_LEVEL) t = (double)cvGetTickCount();
	if(maxDim > IMAGE_SCALE_DIMENSION) mySession->scale = maxDim / (float) IMAGE_SCALE_DIMENSION;
	if(mySession->scale > IMAGE_MAX_SCALE) mySession->scale = IMAGE_MAX_SCALE;
	if(mySession->scale < 1.005f) mySession->scale = 1.0f; // We shouldn't waste time with such small rescales
	mySession->rightImage = cvCreateImage( cvSize(cvRound(mySession->origImage->width / mySession->scale), cvRound(mySession->origImage->height / mySession->scale)),
					IPL_DEPTH_8U, 1 );

	if(mySession->scale > 1.0f)
	{
		IplImage *gray = cvCreateImage( cvSize(mySession->origImage->width, mySession->origImage->height), IPL_DEPTH_8U, 1 );
		cvCvtColor( mySession->origImage, gray, CV_BGR2GRAY );
		cvResize( gray, mySession->rightImage, IMAGE_INTERPOLATION );
		cvReleaseImage( &gray );
	}
	else cvCvtColor( mySession->origImage, mySession->rightImage, CV_BGR2GRAY );

	if(mySession->scale != 1.0f) ci_debug_printf(9, "srv_classify_image: Image Resized - X: %d, Y: %d (shrunk by a factor of %f)\n", mySession->rightImage->width, mySession->rightImage->height, mySession->scale);
	if(CI_DEBUG_LEVEL >= PERF_DEBUG_LEVEL)
	{
		t = cvGetTickCount() - t;
		t = t / ((double)cvGetTickFrequency() * 1000.);
		ci_debug_printf(8, "srv_classify_image: Scaling and Color Prep took: %gms.\n", t);
	}
}
开发者ID:cloudmeapp,项目名称:C-ICAP-Classify,代码行数:30,代码来源:srv_classify_image.c

示例9: main

//=============================================================================
int main(int argc, const char** argv)
{
  //parse command line arguments
  char ftFile[256],conFile[256],triFile[256];
  bool fcheck = false; double scale = 1; int fpd = -1; bool show = true;
  if(parse_cmd(argc,argv,ftFile,conFile,triFile,fcheck,scale,fpd)<0)return 0;

  //set other tracking parameters
  std::vector<int> wSize1(1); wSize1[0] = 7;
  std::vector<int> wSize2(3); wSize2[0] = 11; wSize2[1] = 9; wSize2[2] = 7;
  int nIter = 5; double clamp=3,fTol=0.01;
  FACETRACKER::Tracker model(ftFile);
  cv::Mat tri=FACETRACKER::IO::LoadTri(triFile);
  cv::Mat con=FACETRACKER::IO::LoadCon(conFile);

  //initialize camera and display window
  cv::Mat frame,gray,im; double fps=0; char sss[256]; std::string text;
  CvCapture* camera = cvCreateCameraCapture(CV_CAP_ANY); if(!camera)return -1;
  int64 t1,t0 = cvGetTickCount(); int fnum=0;
  cvNamedWindow("Face Tracker",1);
  std::cout << "Hot keys: "        << std::endl
	    << "\t ESC - quit"     << std::endl
	    << "\t d   - Redetect" << std::endl;

  //loop until quit (i.e user presses ESC)
  bool failed = true;
  while(1){
    //grab image, resize and flip
    IplImage* I = cvQueryFrame(camera); if(!I)continue; frame = I;
    if(scale == 1)im = frame;
    else cv::resize(frame,im,cv::Size(scale*frame.cols,scale*frame.rows));
    cv::flip(im,im,1); cv::cvtColor(im,gray,CV_BGR2GRAY);

    //track this image
    std::vector<int> wSize; if(failed)wSize = wSize2; else wSize = wSize1;
    if(model.Track(gray,wSize,fpd,nIter,clamp,fTol,fcheck) == 0){
      int idx = model._clm.GetViewIdx(); failed = false;
      Draw(im,model._shape,con,tri,model._clm._visi[idx]);
    }else{
      if(show){cv::Mat R(im,cvRect(0,0,150,50)); R = cv::Scalar(0,0,255);}
      model.FrameReset(); failed = true;
    }
    //draw framerate on display image
    if(fnum >= 9){
      t1 = cvGetTickCount();
      fps = 10.0/((double(t1-t0)/cvGetTickFrequency())/1e+6);
      t0 = t1; fnum = 0;
    }else fnum += 1;
    if(show){
      sprintf(sss,"%d frames/sec",(int)round(fps)); text = sss;
      cv::putText(im,text,cv::Point(10,20),
		  CV_FONT_HERSHEY_SIMPLEX,0.5,CV_RGB(255,255,255));
    }
    //show image and check for user input
    imshow("Face Tracker",im);
    int c = cvWaitKey(10);
    if(c == 27)break; else if(char(c) == 'd')model.FrameReset();
  }return 0;
}
开发者ID:coopie,项目名称:Palpitate,代码行数:60,代码来源:face_tracker.cpp

示例10: main

int
main(int argc, char *argv[])
{
    CvCapture *capture = NULL;
    IplImage *src_frame, *image, *dst_frame;
    char *infile, *outfile;
    Matrix matrix;
    Args args;
    int64 t0, t1;
    double tps, deltatime;
    CvVideoWriter *writer;
    CvSize size;
    double fps;
    int frame_count;
    int i;

    infile = argv[1];
    outfile = argv[2];
    args.c = argc - 3;
    for (i = 0; i < 3; i++)
        args.v[i] = argv[i + 3];
    capture = cvCaptureFromFile(infile);
    if (capture == NULL) {
        printf("Could not load video \"%s\".\n", infile);
        return EXIT_FAILURE;
    }
    src_frame = cvQueryFrame(capture);
    fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
    size = cvSize(
        (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
        (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
    );
    writer = cvCreateVideoWriter(outfile, CV_FOURCC('M', 'J', 'P', 'G'), fps, size, 1);
    printf("Saving to \"%s\"...\n", outfile);
    image = cvCreateImage(size, IPL_DEPTH_8U, 1);
    dst_frame = cvCreateImage(size, IPL_DEPTH_8U, 3);
    matrix.width = dst_frame->width;
    matrix.height = dst_frame->height;
    frame_count = 0;
    t0 = cvGetTickCount();
    while ((src_frame = cvQueryFrame(capture)) != NULL) {
        cvCvtColor(src_frame, image, CV_BGR2GRAY);
        matrix.data = (unsigned char *) image->imageData;
        proc(&matrix, &args);
        cvCvtColor(image, dst_frame, CV_GRAY2BGR);
        cvWriteFrame(writer, dst_frame);
        frame_count++;
    }
    t1 = cvGetTickCount();
    tps = cvGetTickFrequency() * 1.0e6;
    deltatime = (double) (t1 - t0) / tps;
    printf("%d frames of %dx%d processed in %.3f seconds.\n",
           frame_count, dst_frame->width, dst_frame->height,
           deltatime);
    cvReleaseVideoWriter(&writer);
    cvReleaseImage(&dst_frame);
    cvReleaseCapture(&capture);
    return EXIT_SUCCESS;
}
开发者ID:lecram,项目名称:ipg,代码行数:59,代码来源:vid.c

示例11: printf

void pixkit::Timer::Start(){
	if (is_started){
		printf("pixkit::timer '%s' is already started. Nothing done.\n", title.c_str());
		start_clock = cvGetTickCount();
		return;
	}
	is_started = true;	n_starts++;	start_clock = cvGetTickCount();
}
开发者ID:JieCyun,项目名称:pixkit,代码行数:8,代码来源:pixkit-timer.cpp

示例12: update

    void update()
    {
        if (!cascade) {
            cvSetNumThreads(cvRound(threads * 100));
            f0r_param_string classifier;
            get_param_value(&classifier, FACEBL0R_PARAM_CLASSIFIER);
            if (classifier) {
                cascade = (CvHaarClassifierCascade*) cvLoad(classifier, 0, 0, 0 );
                if (!cascade)
                    fprintf(stderr, "ERROR: Could not load classifier cascade %s\n", classifier);
                storage = cvCreateMemStorage(0);
            }
            else {
                memcpy(out, in, size * 4);
                return;
            }
        }
        
        // copy input image to OpenCV
        if( !image )
            image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 4);
        memcpy(image->imageData, in, size * 4);
        
        // only re-detect periodically to control performance and reduce shape jitter
        int recheckInt = abs(cvRound(recheck * 1000));
        if ( recheckInt > 0 && count % recheckInt )
        {
            // skip detect
            count++;
//            fprintf(stderr, "draw-only counter %u\n", count);
        }
        else
        {
            count = 1;   // reset the recheck counter
            if (objects) // reset the list of objects
                cvClearSeq(objects);
            
            double elapsed = (double) cvGetTickCount();

            objects = detect();

            // use detection time to throttle frequency of re-detect vs. redraw (automatic recheck)
            elapsed = cvGetTickCount() - elapsed;
            elapsed = elapsed / ((double) cvGetTickFrequency() * 1000.0);

            // Automatic recheck uses an undocumented negative parameter value,
            // which is not compliant, but technically feasible.
            if (recheck < 0 && cvRound( elapsed / (1000.0 / (recheckInt + 1)) ) <= recheckInt)
                    count += recheckInt - cvRound( elapsed / (1000.0 / (recheckInt + 1)));
//            fprintf(stderr, "detection time = %gms counter %u\n", elapsed, count);
        }
        
        draw();
        
        // copy filtered OpenCV image to output
        memcpy(out, image->imageData, size * 4);
        cvReleaseImage(&image);
    }
开发者ID:ttill,项目名称:frei0r,代码行数:58,代码来源:facedetect.cpp

示例13: update

    void update(double time,
                uint32_t* out,
                const uint32_t* in)
    {
        if (cascade.empty()) {
            cv::setNumThreads(cvRound(threads * 100));
            if (classifier.length() > 0) {
                if (!cascade.load(classifier.c_str()))
                    fprintf(stderr, "ERROR: Could not load classifier cascade %s\n", classifier.c_str());
            }
            else {
                memcpy(out, in, size * 4);
                return;
            }
        }

        // sanitize parameters
        search_scale = CLAMP(search_scale, 0.11, 1.0);
        neighbors = CLAMP(neighbors, 0.01, 1.0);

        // copy input image to OpenCV
        image = cv::Mat(height, width, CV_8UC4, (void*)in);

        // only re-detect periodically to control performance and reduce shape jitter
        int recheckInt = abs(cvRound(recheck * 1000));
        if ( recheckInt > 0 && count % recheckInt )
        {
            // skip detect
            count++;
//            fprintf(stderr, "draw-only counter %u\n", count);
        }
        else
        {
            count = 1;   // reset the recheck counter
            if (objects.size() > 0) // reset the list of objects
                objects.clear();
            double elapsed = (double) cvGetTickCount();

            objects = detect();

            // use detection time to throttle frequency of re-detect vs. redraw (automatic recheck)
            elapsed = cvGetTickCount() - elapsed;
            elapsed = elapsed / ((double) cvGetTickFrequency() * 1000.0);

            // Automatic recheck uses an undocumented negative parameter value,
            // which is not compliant, but technically feasible.
            if (recheck < 0 && cvRound( elapsed / (1000.0 / (recheckInt + 1)) ) <= recheckInt)
                    count += recheckInt - cvRound( elapsed / (1000.0 / (recheckInt + 1)));
//            fprintf(stderr, "detection time = %gms counter %u\n", elapsed, count);
        }
        
        draw();

        // copy filtered OpenCV image to output
        memcpy(out, image.data, size * 4);
    }
开发者ID:ddennedy,项目名称:frei0r,代码行数:56,代码来源:facedetect.cpp

示例14: main

int main (int argc, char **argv)
{
    int width=960, height=640;
    IplImage *img=0;
    double c, f;
    f = cvGetTickFrequency()*1000;
    
    int cx = width/2;
    int cy = height/2;
    double radius = 100;
    double angle = 0;
    CvScalar color = cvScalarAll(255);
    
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 1.0, 1.0, 1, CV_AA);
    
    cvNamedWindow ("hexagon", CV_WINDOW_AUTOSIZE);
    while (1) {
        
        // (1)allocate and initialize an image
        img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
        if(img == 0) return -1;
        cvZero(img);
        
        // (2) draw hexagon
        c = cvGetTickCount();
        myHexagon(img, cx, cy, radius, angle, color);
        printf("%fms\n", (cvGetTickCount()-c)/f);
        
        // (3)show the iamge, and press some key
        cvPutText(img, "Coordinate Right(D) Left(A) Up(W) Down(X)", cvPoint(10, 20), &font, cvScalarAll(255));
        cvPutText(img, "Rotate Right(R) Left(E)", cvPoint(10, 40), &font, cvScalarAll(255));
        cvPutText(img, "Radius Big(V) Small(C)", cvPoint(10, 60), &font, cvScalarAll(255));
        cvPutText(img, "Quit(Q, esc)", cvPoint(10, 80), &font, cvScalarAll(255));
        char s[64];
        sprintf(s, "cx:%d cy:%d radius:%f angle:%f", cx, cy, radius, angle);
        cvPutText(img, s, cvPoint(10, 110), &font, cvScalarAll(255));
        
        cvShowImage ("hexagon", img);
        char key = cvWaitKey (0);
        if (key == 27 || key == 'q') break;
        else if (key == 'r') angle += 5;
        else if (key == 'e') angle -= 5;
        else if (key == 'a') cx -= 5;
        else if (key == 'd') cx += 5;
        else if (key == 'w') cy -= 5;
        else if (key == 'x') cy += 5;
        else if (key == 'v') radius += 5;
        else if (key == 'c') radius -= 5;
    }
    
    cvDestroyWindow("hexagon");
    cvReleaseImage(&img);
    
    return 0;
}
开发者ID:shugoyamaguchi,项目名称:computer_vision,代码行数:56,代码来源:hexagon.c

示例15: main

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;
}
开发者ID:yksz,项目名称:ComputerVision-misc,代码行数:55,代码来源:main.c


注:本文中的cvGetTickCount函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。