⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application.c

📁 jiance jichang paidui de moxing.
💻 C
字号:
/**
* @file Application.c
* @brief
* Copyright (c) 2007,SICE
* All rights reserved.
*
* 揈梫丗
*
* Ver : 0.1
* 嶌幰 : 錖丂愯摀
* 峏怴帪娫 : 2007/11/15
*/
#ifndef _Application_H_ 
#define _Application_H_
#include <stdio.h>
#include <math.h>

#include <cv.h>
#include <highgui.h>

#include "common.h"
#include "queuearea.h"
#endif 

#if 1//僌儘乕僶儖曄悢
static IplImage *pImgSrc = NULL;
static IplImage *pImgSrcCpy = NULL;
static IplImage *pImgGray = NULL;

char strText[255];
char strTemp[20];
#endif

#if 1//娭悢惡柧
void on_mouse(int event, int x, int y, int flags, void* param);
#endif

int main(int argc, char** argv)
{
	double t = 0.0;

	pImgSrc = cvLoadImage("kukou3.jpg",1);

	if(pImgSrc == NULL)
	{
		printf("Image Load failed.\n");
		return 0;
	}

	printf("Image Load success......\n");

	cvNamedWindow("KUKOU-SRC", 1);
	cvSetMouseCallback("KUKOU-SRC", on_mouse, NULL);

	pImgSrcCpy = cvCloneImage(pImgSrc);
	pImgGray = cvCreateImage(cvGetSize(pImgSrc), 8, 1);
	pImgGray->origin = pImgSrc->origin;

	cvCvtColor(pImgSrc, pImgGray, CV_BGR2GRAY);

	strcpy(strText, "Width:");
	itoa(pImgSrcCpy->width, strTemp, 10);
	strcat(strText, strTemp);strcat(strText, ", Height:");
	itoa(pImgSrcCpy->height, strTemp, 10);strcat(strText, strTemp);
	cmPutText(pImgSrcCpy, strText, cvPoint(530,10), CV_RGB(0,255,0));

	while(1)
	{
		cvShowImage("KUKOU-SRC", pImgSrcCpy);
		cvWaitKey(33);
		if (cvGetWindowHandle("KUKOU-SRC") == NULL)
		{
			break;
		}
	}

	t = (double)cvGetTickCount();
	//cmConstructQueueAreaModule(pImgGray, cvPoint(85,176), cvPoint(363,144), cvPoint(272,312), cvPoint(622,227) ,3);//kukou
	//cmConstructQueueAreaModule(pImgGray, cvPoint(87,180), cvPoint(286,157), cvPoint(372,367), cvPoint(645,275), 4);//kukou
	cmConstructQueueAreaModule(pImgGray, cvPoint(67,295),cvPoint(461,227), cvPoint(317,446), cvPoint(756,328), 3);//kukou3.jpg

	//cmConstructQueueAreaModule(pImgGray, cvPoint(14,105), cvPoint(189,72), cvPoint(70,202), cvPoint(319,109), 4);//test
    
	getCurrentVisibleQueueLines(pImgSrcCpy, cvPoint(162,338),cvPoint(561,261), cvPoint(318,436), cvPoint(754,319));//kukou3.jpg
	
	t = (double)cvGetTickCount() - t;
    printf( "Construct time = %gms\n", t/((double)cvGetTickFrequency()*1000.) );

	cvWaitKey(0);
	cvReleaseImage(&pImgSrc);
	cvReleaseImage(&pImgSrcCpy);
	cvDestroyAllWindows();
}

void on_mouse(int event, int x, int y, int flags, void* param)
{
	if( !pImgSrcCpy )
		return;

	if(pImgSrcCpy->origin)
	{
		y = pImgSrcCpy->height-y;
	}

    switch(event)
    {
		case CV_EVENT_LBUTTONDOWN:
			strcpy(strText, "(");
			itoa(x, strTemp, 10);
			strcat(strText, strTemp);strcat(strText, ", ");
			itoa(y, strTemp, 10);strcat(strText, strTemp);
			strcat(strText, ")");
			cmPutText(pImgSrcCpy, strText, cvPoint(x,y), CV_RGB(255,255,0));
			break;
		case CV_EVENT_LBUTTONUP:

			break;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -