void SimpleFilter::drawDebugInfo( IplImage* frame, QVector<Vertex> qrCodes, QVector<CvSeq*> contours )
{
    CvPoint g;
    g.x=30;
    g.y=30;
    CvFont sized;
    cvInitFont(&sized, CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, 1.0);
    cvPutText( frame, (QString::number(errorAngle)).toAscii(), g, &sized, CV_RGB( 0, 255, 255 ) );

    g.x=30;
    g.y=90;
    cvPutText( frame, (QString::number(errorSide)).toAscii(), g, &sized, CV_RGB( 0, 255, 255 ) );


    /////////////////////////////////////////////////////
    for( int indx = 0; indx < contours.size(); ++indx )
    {
        cvDrawContours(frame, contours[indx], CV_RGB(255,216,0), CV_RGB(0,0,250), 0, 2, 8);
    }

    /////////////////////////////////////////////////////
    qDebug()<<qrCodes.size();

    for(int i=0;i<qrCodes.count();i++)
    {
        qDebug()<<"POINT: "<<qrCodes.count();
        cvDrawLine( frame, qrCodes.at(i).p1, qrCodes.at(i).p2, CV_RGB(30,216,30), 2, 8, 0 );
        cvDrawLine( frame, qrCodes.at(i).p1, qrCodes.at(i).p3, CV_RGB(30,216,30), 2, 8, 0 );
        cvDrawLine( frame, qrCodes.at(i).p2, qrCodes.at(i).p3, CV_RGB(30,216,30), 2, 8, 0 );
    }
}
/**
 *  Draw a line from the middle of frame to the given point
 *  @param Image to draw on
 *  @param Object to draw line to
 *  @param Middle of frame
 */
int ColorTracking::drawWidthDiff (IplImage *image, CvPoint object, CvPoint middlePoint)
{
    int xDistance = object.x - middlePoint.x;
	
    cvDrawLine(image, object, middlePoint, CV_RGB(0, 255, 0), 2);
	
    return xDistance;
}
Example #3
0
void crossDraw(IplImage* src, CvPoint* centCross, CvSize srcSiz) {
	//
	CvPoint a;
	CvPoint b;
	CvPoint c;
	CvPoint d;
	a.x = ( (centCross->x - 2) >= 0 ) ? ( centCross->x - 2 ) : ( ( (centCross->x - 1) >= 0 ) ? ( centCross->x - 1 ) : 0 );
	a.y = centCross->y;
	b.x = ( (centCross->x + 2) <= srcSiz.width ) ? ( centCross->x + 2 ) : ( ( (centCross->x + 1) <= srcSiz.width ) ? ( centCross->x + 1 ) : srcSiz.width );
	b.y = centCross->y;
	c.x = centCross->x;
	c.y = ( (centCross->y - 2) >= 0 ) ? ( centCross->y - 2 ) : ( ( (centCross->y - 1) >= 0 ) ? ( centCross->y - 1 ) : 0 );
	d.x = centCross->x;
	d.y = ( (centCross->y + 2) <= srcSiz.height ) ? ( centCross->y + 2 ) : ( ( (centCross->y + 1) <= srcSiz.height ) ? ( centCross->y + 1 ) : srcSiz.height );
	cvDrawLine(src, a, b, CVX_PURE);
	cvDrawLine(src, c, d, CVX_PURE);	
}
Example #4
0
File: flow.cpp Project: pushkar/xyz
void Flow::draw(IplImage** img) {
	for (int i = 0; i < dist_img_1->height; i+=10) {
		for (int j = 0; j < dist_img_1->width; j+=10) {
			vx = cvGet2D(velx, i, j);
			vy = cvGet2D(vely, i, j);
			cvDrawLine(*img, cvPoint(j, i), cvPoint(j+vy.val[0], i+vx.val[0]),
					CV_RGB(255, 255, 255), 1);
		}
	}
}
void OpenCVPlotter::PlotMuLevel(double level, double scaling, Color color)
{
    if (CantPlotHistogram()) return;

    CvPoint start, finish;
    start.x = HNormalX2ImageX(0.0);
    start.y = HNormalY2ImageY(level * scaling);
    finish.x = m_Data->histogramImg->width;
    finish.y = HNormalY2ImageY(level * scaling);
    cvDrawLine(m_Data->histogramImg, start, finish, GetCvColor(color));

    //print mu level value
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 0.5, 0.5);
    char value[256];
    sprintf(value, "%.1f", level);
    cvPutText(m_Data->histogramImg, value, start, &font, GetCvColor(Color_Black));
}
Example #6
0
int trackingC::step(IplImage* img){
	CvFont font;
	cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 1, 1);

	if(tracked){
		if(!gone && visible && !inMotion){
			cvDrawCircle(img, this->position, approxSize, cvScalar(0, 0, 0), -1);
			cvDrawLine(img, position, cvPoint(position.x+dTraveled.x, position.y+dTraveled.y), cvScalar(255,255,255), 3);
			cvPutText(img,  "D", cvPoint(position.x, position.y-10), &font, cvScalar(0,255,0));
		}else if (!gone && visible && inMotion){
			cvDrawCircle(img, this->position, approxSize, cvScalar(200, 100, 0), 3);
			cvPutText(img,  "M", cvPoint(position.x, position.y-10), &font, cvScalar(0,255,0));
		}else if(!gone){
			cvDrawCircle(img, this->position, approxSize, cvScalar(255, 255, 255), -1);
			cvPutText(img,  "X", cvPoint(position.x, position.y-10), &font, cvScalar(0,255,0));
		}
	}

	if(!viewed){
		timerReset ++;
		isVisible = false;
		if(timerReset > 10 && timerReset < 60){
			if(visible)
				isOcluded = true;
			visible = false;
		}
		else if(timerReset >= 60){
			if(!gone){
				isGone = true;
				isOcluded = false;
			}else{
				isGone = false;
			}
			gone = true;
			
		}
	}

	viewed = false;

	return 0;
}
Example #7
0
void showDiagImg(int w, int h, SGPath *path, size_t pathCount)
{
    int scale = 8;
    CvMat *mat = cvCreateMat(h*scale, w*scale, CV_8UC3);
    cvRectangle(mat, 
                cvPoint(0, 0), 
                cvPoint((w - 1)*scale, (h - 1)*scale), 
                CV_RGB(0, 0, 0), -1);
          
    for (int i=0; i < pathCount; i++) 
    {
        cvDrawLine(mat, 
                   cvPoint(path[i].start.x*scale, 
                           path[i].start.y*scale),
                   cvPoint(path[i].end.x*scale, 
                           path[i].end.y*scale), 
                   CV_RGB(255, 0, 0));
    }
    cvSaveImage("diags.png", mat);
    cvReleaseMat(&mat);
}
void DibujarBox2D(IplImage *imagen,CvBox2D BoundBox)
{

	int x0,y0,x1,y1,x,y;

	float angulo;

	angulo=(BoundBox.angle)*3.14/180;
//------------------------------------------------------------------------------------------------
	x=-BoundBox.size.width/2;
	y=BoundBox.size.height/2;

	x0=BoundBox.center.x+x*cos(angulo)-y*sin(angulo);
	y0=BoundBox.center.y+x*sin(angulo)+y*cos(angulo);

	x=BoundBox.size.width/2+2;
	y=BoundBox.size.height/2+2;

	x1=BoundBox.center.x+x*cos(angulo)-y*sin(angulo);
	y1=BoundBox.center.y+x*sin(angulo)+y*cos(angulo);


	cvDrawLine(imagen,cvPoint(x0,y0),cvPoint(x1,y1),CV_RGB(0xff,0xff,0xff),1,8,0);

	//--------------------------------------------------------------------------------------------

	x0=x1;
	y0=y1;

	x=BoundBox.size.width/2;
	y=-BoundBox.size.height/2;

	x1=BoundBox.center.x+x*cos(angulo)-y*sin(angulo);
	y1=BoundBox.center.y+x*sin(angulo)+y*cos(angulo);

	cvDrawLine(imagen,cvPoint(x0,y0),cvPoint(x1,y1),CV_RGB(0xff,0xff,0xff),1,8,0);
//------------------------------------------------------------------------------------------------------
	x0=x1;
	y0=y1;

	x=-BoundBox.size.width/2;
	y=-BoundBox.size.height/2;


	x1=BoundBox.center.x+x*cos(angulo)-y*sin(angulo);
	y1=BoundBox.center.y+x*sin(angulo)+y*cos(angulo);

	cvDrawLine(imagen,cvPoint(x0,y0),cvPoint(x1,y1),CV_RGB(0xff,0xff,0xff),1,8,0);
//-----------------------------------------------------------------------------------------------
	x0=x1;
	y0=y1;

	x=-BoundBox.size.width/2;
	y=BoundBox.size.height/2;

	x1=BoundBox.center.x+x*cos(angulo)-y*sin(angulo);
	y1=BoundBox.center.y+x*sin(angulo)+y*cos(angulo);

	cvDrawLine(imagen,cvPoint(x0,y0),cvPoint(x1,y1),CV_RGB(0xff,0xff,0xff),1,8,0);
//-------------------------------------------------------------------------------------------
}