int main(int argc, char * const *argv) { int M = 256; cv::Size imsize(512, 512); cv::Size psize(32,32); int lbdType; if (strncmp(argv[1], "freak", 5) == 0) { lbdType = lbd::eTypeFreak;; } else { if (strncmp(argv[1], "brief", 5) == 0) { lbdType = lbd::eTypeBrief; } else { std::cerr << "Error. The parameter should be either freak or brief.\n"; return -1; } } lts2::LBDOperator *LBD = lts2::CreateLbdOperator(lbdType, M); LBD->initWithPatchSize(psize); cv::Mat destImage(cv::Size(imsize), CV_8UC3); LBD->drawSelfAsCircles(destImage); cv::imwrite(argv[2], destImage); return EXIT_SUCCESS; }
int main(void) { printf("ORF pid %d\n", (int) getpid()); SRCAM cam; // int ret = SR_OpenDlg(&cam, 2, 0); // 2: call open dialog, 0: no parent window // int ret = SR_OpenETH(&cam, "192.168.1.33"); int ret = SR_OpenETH(&cam, "169.254.1.33"); if(ret<=0) return -1; // ret holds the number of cameras found cv::Size imsize(SR_GetCols(cam), SR_GetRows(cam)); // SR image size int sizebytes = 2 * imsize.area() * sizeof(unsigned short); // number of bytes sent from the SR // namedWindow("mainWin",WINDOW_AUTOSIZE ); cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); int sizestep = sizeof(float)*3; // size step from one xyz component to the next int c=-1; // user input variable // enable software trigger mode so that the LEDs will only turn // on when SR_Acquire() is called SR_SetMode(cam,AM_SW_TRIGGER); std::time_t start_time = std::time(0); while(c==-1) // infinite loop, breaks if key pressed { ret = SR_Acquire(cam); cv::Mat xyz(imsize, CV_32FC3, cv::Scalar::all(0)); if(ret!=sizebytes) break; // the coordinates are stored as three channels in the format // (x1, y1, z1, x2, y2, z2, ... ) squentially row by row SR_CoordTrfFlt( cam, &((float*)xyz.ptr())[0], // pointer to first x &((float*)xyz.ptr())[1], // pointer to first y &((float*)xyz.ptr())[2], // pointer to first z sizestep, sizestep, sizestep); // increments to next element cv::Mat z, z_display; // z channel and output image extractImageCOI(&CvMat(xyz), z, 2); // extract the z channel (change the 2 for another channel) z.convertTo(z_display, CV_8UC1, 256.0 / 5.0, 0); // convert to 8 bit (0..255) values, here for 5 meter camera cv::imshow("mainWin", z_display); // display image std::time_t t = std::time() - start_time; printf("ORF data taken at %d seconds\n", t); //std::cout << "ORF data taken at" << t << "seconds\n"; std::stringstream filename; filename << "./ORF_photos/" << t << ".bmp" cv::imwrite(filename.str(),z_display); c = cvWaitKey(1000); // wait 1 sec before continuing loop. if user presses a button, the loop will exit } SR_Close(cam); return 0; }