📄 stdafx.cpp
字号:
// stdafx.cpp : source file that includes just the standard includes
// MRF_imgSeg.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
int mouseEnable=0;
IplImage *img;
CvRect selection;
CvRect area[30];
int classN;
int selected;
int Number=0;
void on_mouse( int event, int x, int y, int flags, void* param )
{
static int select_object=0;
static CvPoint origin;
if (img==NULL) {
return;
}
if (!mouseEnable) {
return;
}
if( img->origin )
y = img->height - y;
if( select_object )
{
selection.x = MIN(x,origin.x);
selection.y = MIN(y,origin.y);
selection.width = selection.x + CV_IABS(x - origin.x);
selection.height = selection.y + CV_IABS(y - origin.y);
selection.x = MAX( selection.x, 0 );
selection.y = MAX( selection.y, 0 );
selection.width = MIN( selection.width, img->width );
selection.height = MIN( selection.height, img->height );
selection.width -= selection.x;
selection.height -= selection.y;
}
switch( event )
{
case CV_EVENT_LBUTTONDOWN:
origin = cvPoint(x,y);
selection = cvRect(x,y,0,0);
select_object = 1;
break;
case CV_EVENT_LBUTTONUP:
select_object = 0;
selected=1;
if( selection.width > 0 && selection.height > 0 )
{
area[Number]=selection;
Number++;
if (Number>=classN) {
Number=0;
mouseEnable=0;
}
}
AfxGetMainWnd()->PostMessage(WM_LBUTTONUP);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -