static void draw_crosshairs(IplImage *image, float x, float y, float size, double color) { /* Show some simple crosshairs on an image at the given point, * antialiased with subpixel positioning. */ CvPoint endpoint1, endpoint2; endpoint1.x = (int)((x - size/2) * 16 + 0.5); endpoint1.y = (int)(y * 16 + 0.5); endpoint2.x = (int)((x + size/2) * 16 + 0.5); endpoint2.y = (int)(y * 16 + 0.5); cvLineAA(image, endpoint1, endpoint2, color, 4); endpoint1.y = (int)((y - size/2) * 16 + 0.5); endpoint1.x = (int)(x * 16 + 0.5); endpoint2.y = (int)((y + size/2) * 16 + 0.5); endpoint2.x = (int)(x * 16 + 0.5); cvLineAA(image, endpoint1, endpoint2, color, 4); }
static void draw_box(IplImage *image, CvBox2D box, double color) { CvPoint2D32f boxPoints[4]; /* CamShift seems to get this backwards */ box.angle = -box.angle; cvBoxPoints(box, boxPoints); cvLineAA(image, cvPoint((int)boxPoints[0].x, (int)boxPoints[0].y), cvPoint((int)boxPoints[1].x, (int)boxPoints[1].y), color); cvLineAA(image, cvPoint((int)boxPoints[1].x, (int)boxPoints[1].y), cvPoint((int)boxPoints[2].x, (int)boxPoints[2].y), color); cvLineAA(image, cvPoint((int)boxPoints[2].x, (int)boxPoints[2].y), cvPoint((int)boxPoints[3].x, (int)boxPoints[3].y), color); cvLineAA(image, cvPoint((int)boxPoints[3].x, (int)boxPoints[3].y), cvPoint((int)boxPoints[0].x, (int)boxPoints[0].y), color); }
void ConformalResizing::ShowConstrains(const IplImage *pBackGround, const vector<ConstrainUnits>& quads, const vector<ConstrainUnits>& qaud5s, const vector<ConstrainUnits>& edges, const char *winName /* = */, const int waite /* = 0 */, const char* saveName /* = NULL */) { IplImage* pMixedImg = cvCloneImage(pBackGround); cvNamedWindow(winName); // Show quads for (size_t i = 0; i < quads.size(); i++) { CvPoint pnts[4]; for (int j = 0; j < 4; j++) { pnts[j].x = (int)(quads[i].pnts[j].x); pnts[j].y = (int)(quads[i].pnts[j].y); } cvLineAA(pMixedImg, pnts[0], pnts[1], 255); cvLineAA(pMixedImg, pnts[0], pnts[2], 255); cvLineAA(pMixedImg, pnts[3], pnts[1], 255); cvLineAA(pMixedImg, pnts[3], pnts[2], 255); } // Show qaud5s for (size_t i = 0; i < qaud5s.size(); i++) { CvPoint pnts[5]; for (int j = 0; j < 5; j++) { pnts[j].x = (int)(qaud5s[i].pnts[j].x); pnts[j].y = (int)(qaud5s[i].pnts[j].y); } cvLineAA(pMixedImg, pnts[0], pnts[1], 255); cvLineAA(pMixedImg, pnts[0], pnts[2], 255); cvLineAA(pMixedImg, pnts[3], pnts[1], 255); cvLineAA(pMixedImg, pnts[3], pnts[2], 255); cvLineAA(pMixedImg, pnts[0], pnts[4], 128); cvLineAA(pMixedImg, pnts[1], pnts[4], 128); cvLineAA(pMixedImg, pnts[2], pnts[4], 128); cvLineAA(pMixedImg, pnts[3], pnts[4], 128); } // Show edges for (size_t i = 0; i < edges.size(); i++) { CvScalar color; if(ispg) color=GenColor1(i); else color=GenColor(i); //swap(color.val[0],color.val[2]); for (int j = 0; j < edges[i].n; j++) { CvPoint point = cvPoint((int)(edges[i].pnts[j].x + 0.5), (int)(edges[i].pnts[j].y + 0.5)); //cvCircle(pMixedImg, point, 3, CmShow::gColors[i % CM_SHOW_COLOR_NUM], 2); cvCircle(pMixedImg, point, 3, color, 2); //cvCircle(pMixedImg, point, 3, CmShow::gColors[edges[i].ind[j] % CM_SHOW_COLOR_NUM], 2); } } cvNamedWindow(winName); cvShowImage(winName, pMixedImg); if (saveName != NULL) cvSaveImage(saveName, pMixedImg); cvReleaseImage(&pMixedImg); }