/** * \brief Combine image, mask and center into a color image */ ImagePtr VCurveFocusWork::combine(ImagePtr image, FWHMInfo& fwhminfo) { // first build the red channel from the mask Image<unsigned char> *red = dynamic_cast<Image<unsigned char> *>(&*fwhminfo.mask); if (NULL == red) { throw std::logic_error("internal error, mask has not 8bit pixel type"); } // then build the green channel from the original image Image<unsigned char> *green = FocusWork::green(image); ImagePtr greenptr(green); // create the blue image CrosshairAdapter<unsigned char> crosshair(image->size(), fwhminfo.maxpoint, 20); CircleAdapter<unsigned char> circle(image->size(), fwhminfo.center, fwhminfo.radius); MaxAdapter<unsigned char> blue(crosshair, circle); // now use a combination adapter to put all these images together // into a single color image CombinationAdapter<unsigned char> combinator(*red, *green, blue); Image<RGB<unsigned char> > *result = new Image<RGB<unsigned char> >(combinator); return ImagePtr(result); }
static void get_pointer(double *x, double *y, int *state) { Point mouse; EventModifiers modifiers; Rect rect; int mousex, mousey; GetWindowPortBounds(p->win, &rect); GetMouse(&mouse); mousex = mouse.h; mousey = mouse.v; crosshair(mousex, mousey); *state = GKS_K_STATUS_OK; do { get_mouse(&mouse, &modifiers); if (mousex != mouse.h || mousey != mouse.v) { crosshair(mousex, mousey); mousex = mouse.h; mousey = mouse.v; crosshair(mousex, mousey); } usleep(10000); if (!(modifiers & 0x80) && modifiers & 0xff00) { *state = GKS_K_STATUS_NONE; break; } } while (modifiers); crosshair(mousex, mousey); DC_to_NDC(mousex, mousey, *x, *y); }
static void CheckGamePatterns(int sizex, int sizey, int patID) { // Get crosshair coordinate (centre of screen) Point2f crosshair(sizex / 2, sizey / 2); if (patternsCoordinates[patID].size()) { // Get distance from crosshair to pattern int dist = norm(patternsCoordinates[patID][4] - crosshair); //cout << dist << endl; // Check distance and drone altitude if (dist < 200 && ardrone.getAltitude() < 0.7) { // Start current pattern seen timer int now = cvGetTickCount(); int passedSinceSeen = ((now - patternTimer) / (cvGetTickFrequency() * 1000)) / 1000; cout << passedSinceSeen << endl; // Check if pattern is within range for more than 2 seconds if (true) { //if (passedSinceSeen > 1) { switch (patID) { case 1: cout << "!!!! PLATFORM" << endl; if (peoplePicked) { points += 1000; peoplePicked = false; } if (cratePicked) { points += 100; cratePicked = false; } break; case 2: if (gameOn) { cout << "!!!! PEOPLE" << endl; peoplePicked = true; } break; case 3: if (gameOn) { cout << "!!!! CRATE" << endl; cratePicked = true; } break; default: break; } } } else patternTimer = cvGetTickCount(); } }
static void rtbox(double r,double theta,double wtheta,const char *label) { coord v[4]; double htheta,hr; htheta=wtheta/2; hr=r*htheta; v[0]=rt(r-hr,theta-htheta); v[1]=rt(r+hr,theta-htheta); v[2]=rt(r+hr,theta+htheta); v[3]=rt(r-hr,theta+htheta); startgroup(); printf("<path "LT" d=\"M%f %f L%f %f L%f %f L%f %f Z\"/>\n", XY(v[0]),XY(v[1]),XY(v[2]),XY(v[3])); crosshair(rt(r,theta),5); text_cen(rt(r+0.8*hr,theta),theta,24,label); endgroup(); }
int main(void) { const double scale=100; double inner=2.80,outer=3.40; double lp=29.53; /* lunar period for earthly observer */ int i; start(8.5,11,scale); text_cen(xy(0,scale*(-1-outer)),0,36,"Lunar Calendar Template"); /* boudaries */ circle(xy(0,0),scale*3.75); circle(xy(0,0),scale*2.25); //circle(xy(0,0),scale*inner); //circle(xy(0,0),scale*outer); crosshair(xy(0,0),0.1*scale); startgroup(); for(i=0;i<31;i++) { char date[6]; double r; #if SPIRAL r=(inner + (outer-inner)*i/lp); #endif #if TWOLAYER r=((i<29)?inner:outer); #endif sprintf(date,"%d",1+i); rtbox(r*scale,2*pi*i/lp,2*pi/lp,date); } endgroup(); end(); return 0; }