예제 #1
0
/////////////////////////////////////////////////////////////////////////////
// CResizeView message handlers
void CResizeView::ShowOnDc(const IplImage*img,int idx /* = 0 */,int idy /* =0 */,const char * title /* = */ )
{
	CClientDC dc(this);	
	OnPrepareDC(&dc);
	CImage image;
	//image.Load(path);
	image.CopyOf((IplImage *)img);
	//HDC hdc = ::GetDC(this->m_hWnd);   
	//image.Draw(hdc, 300, 200); 
	RECT * tmpRect = new RECT();
	tmpRect->right = image.Width() + idx;
	tmpRect->left = 0 + idx;
	tmpRect->top = 0 + idy;
	tmpRect->bottom = image.Height() + idy;
	image.DrawToHDC(dc,tmpRect);
	dc.TextOut(idx,image.Height() + idy,title);
	//UpdateData(FALSE);	
	OnDraw(&dc);
}
예제 #2
0
// Callback function ----------------------------------------------------------
void testcallback(IplImage* img)
{
    assert (img);
    lastframe.Destroy();
    lastframe.Create(img->width,img->height,24,img->origin);
    lastframe.CopyOf(img);
    
    if (view.m_track) {

        if (!view.m_trackinit) {
            view.StartTracking(lastframe);
            view.m_trackinit = true;
        }

        view.TrackFeatures(lastframe);
        
        //double kx = (double)view.m_w/img->width;
        //double ky = (double)view.m_h/img->height;
        
        if( !view.m_night_mode )
        {
            
        }
        else
        {
            //iplSet( img, 0 );
            CvPoint tl = {0,0};
            CvPoint br = {img->width,img->height};
            //cvRectangle(img, tl, br, 0, (img->width > img->height) ? img->width : img->height);
            //cvRectangle(img, tl, br, 0, 255);
            memset(img->imageData,0,img->imageSize);
        }
        
        int i, count = view.m_tracker.GetCount();
        const PointArray& array = view.m_tracker.GetPoints();

        cvCircle( img, P, cvRound(3), CV_RGB(0,0,255));
                
        for( i = 0; i < count; i++ )
        {
            CvPoint pt;
            int color;
            if( i != view.m_moved_idx )
            {
                pt = cvPoint( cvRound(array[i].x), cvRound(array[i].y));
                color = CV_RGB(0,255,0);
            }
            else
            {
                pt = cvPoint( cvRound(view.m_moved_point.x),
                    cvRound(view.m_moved_point.y));
                color = CV_RGB(255,0,0);
            }
            cvCircle( img, pt, 1, color, CV_FILLED );
        }
    }
    else
    {
        if  (view.m_trackinit)
        {
            view.StopTracking();
            view.m_trackinit = false;
        }
    }
    
#ifdef WIN32
    Sleep(10);
#endif
}