void init(){ grabber.init(pa("-i")); bool c_arg = pa("-c"); gui << Draw().handle("draw").label("input image") << Image().handle("cropped").label("cropped") << ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1) << Button("save as ..").handle("saveAs") << Button("overwrite input").handle("overwrite") << Combo("0,90,180,270").handle("rot").label("rotation") << CheckBox("rectangular",!pa("-r")).handle("rect") << Button("Batch crop...").handle("batch") << ( HBox().label("rectification size") << Spinner(1,4096,640).handle("s1") << Label(":") << Spinner(1,4096,480).handle("s2") ) << (HBox() << Fps().handle("fps") << CamCfg() ) ) << Show(); if(!c_arg){ gui["batch"].registerCallback(batch_crop); } const ImgBase *image = grabber.grab(); if(!c_arg){ mouse_1 = new Mouse1(image->getSize()); gui["draw"].install(mouse_1); } mouse_2 = new Mouse2(image->getSize()); gui["draw"].install(mouse_2); DrawHandle draw = gui["draw"]; draw->setImageInfoIndicatorEnabled(false); if(!c_arg){ gui["rect"].registerCallback(rectangular_changed); rectangular_changed(); if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){ gui["overwrite"].disable(); }else{ gui["overwrite"].registerCallback(overwrite); } gui["saveAs"].registerCallback(save_as); } }
void MainMenu() { func = -1; while (!stop_button()) { funcLast = func; func = ScaleKnob(1, 27); if (FDispMenu(1, "Calibrate Lookdown")) CalibrateLookdown(); if (FDispMenu(2, "Compete!")) Compete(); if (FDispMenu(3, "Placebo")) Placebo(); if (FDispMenu(4, "Dance!")) Chop(10); if (FDispMenu(5, "Calibrate Soft")) CalibrateSoft(); if (FDispMenu(6, "Calibrate Hard")) CalibrateHard(); if (FDispMenu(7, "Speed Calibration")) CalibrateSpeed(); if (FDispMenu(8, "Lookdown Test")) LookdownTest(); if (FDispMenu(9, "Orientation")) Orient(); if (FDispMenu(10, "Straight 1000")) Move(1000,1000); if (FDispMenu(11, "Left 90 Soft")) Soft(90, 1); if (FDispMenu(12, "Left 90 Hard")) Hard(90); if (FDispMenu(13, "Find Line")) FindLine(); if (FDispMenu(14, "Line Follow")) LineFollower(); if (FDispMenu(15, "Record")) RecordMove(WSetting("Record move", 0, 9)); if (FDispMenu(16, "Playback")) PlayMove(WSetting("Play move", 0, 9)); /* hbtest.c functions */ if (FDispMenu(17, "Servo Test")) ServoTest(); if (FDispMenu(18, "Calibrate Gate")) CalibrateGate(); if (FDispMenu(19, "Soft Turn Test")) SoftTest(); if (FDispMenu(20, "Hard Turn Test")) HardTest(); if (FDispMenu(21, "Spin Test!")) Spinner(); if (FDispMenu(22, "Shake Test!")) Shaker(); if (FDispMenu(23, "Bump Test")) BumpTest(); if (FDispMenu(24, "Test Motors")) testmotors(); if (FDispMenu(25, "Test Digitals")) testdigitals(); if (FDispMenu(26, "Test Analogs")) testanalogs(); if (FDispMenu(27, "Assert Enable")) AssertEnable(); } }
void CL_PingPong::Start(unsigned int num_runs, const std::vector<int> options) { int ret = 0; int wg = 256; auto tid = this_thread::get_id(); std::cout << DASH50 << "\n Ping Pong Test\n"; // decode options uint16_t power; if (options.size() > 0) { power = options[0]; } else { cout << "Power of numbers to swap?: (0 for default)" << std::endl; power = promptValidated<int, int>("Power: ", [](int i) { return (i >= 0 && i <= 256); }); } if (power == 0) { power = DEFAULTPOWER; } // load a pointelss kernel auto prog = cl::load_program("hello.cl", ctx, CtxDevices); cl_kernel kernel = clCreateKernel(prog, "pointless", &ret); assert(ret == CL_SUCCESS); /* Create Random Numbers */ cl_uint maxN = 1 << power; size_t szPC = maxN * sizeof(cl_uint); cl_uint *rndData = new cl_uint[maxN]; // create buffers cl_mem buf1 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, szPC, NULL, &ret); cl_mem buf2 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, szPC, NULL, &ret); // try to place on correct gpus, broken AF // clEnqueueMigrateMemObjects(cq[0], 1, &buf1, CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED, NULL, // NULL, NULL); // clEnqueueMigrateMemObjects(cq[1], 1, &buf2, CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED, NULL, // NULL, NULL); // send data to buf 1 ret = clEnqueueWriteBuffer(cq[0], buf1, CL_TRUE, 0, szPC, &rndData[0], 0, NULL, NULL); // blocking ret = clFinish(cq[0]); // Wait untill all commands executed. assert(ret == CL_SUCCESS); unsigned int runs = 0; running = true; should_run = true; ResultFile r; r.name = "CLPingPong" + to_string(maxN); r.headdings = {"A to B", "B to A"}; while (ShouldRun() && runs < num_runs) { vector<unsigned long long> times; unsigned int percentDone = (unsigned int)(floor(((float)runs / (float)num_runs) * 100.0f)); cout << "\r" << Spinner(runs) << "\t" << runs << "\tPercent Done: " << percentDone << "%" << std::flush; // make new numbers for (cl_uint i = 0; i < maxN; i++) { cl_uint x = (cl_uint)0; rndData[i] = (x << 14) | ((cl_uint)rand() & 0x3FFF); rndData[i] = (x << 14) | ((cl_uint)rand() & 0x3FFF); } Timer time_swap_a; ret = clEnqueueWriteBuffer(cq[1], buf2, CL_TRUE, 0, szPC, buf1, 0, NULL, NULL); // blocking for (auto q : cq) { ret = clFinish(q); // Wait untill all commands executed. assert(ret == CL_SUCCESS); } ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)(&buf2)); assert(ret == CL_SUCCESS); size_t global_work_size[1] = {maxN}; ret = clEnqueueNDRangeKernel(cq[1], kernel, 1, // work_dim 0, // global_work_offset global_work_size, // global_work_size NULL, // local_work_size 0, // num_events_in_wait_list NULL, // event_wait_list NULL // event ); for (auto q : cq) { ret = clFinish(q); // Wait untill all commands executed. assert(ret == CL_SUCCESS); } time_swap_a.Stop(); times.push_back(time_swap_a.Duration_NS()); Timer time_swap_b; ret = clEnqueueWriteBuffer(cq[0], buf1, CL_TRUE, 0, szPC, buf2, 0, NULL, NULL); // blocking for (auto q : cq) { ret = clFinish(q); // Wait untill all commands executed. assert(ret == CL_SUCCESS); } ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)(&buf1)); assert(ret == CL_SUCCESS); ret = clEnqueueNDRangeKernel(cq[0], kernel, 1, // work_dim 0, // global_work_offset global_work_size, // global_work_size NULL, // local_work_size 0, // num_events_in_wait_list NULL, // event_wait_list NULL // event ); for (auto q : cq) { ret = clFinish(q); // Wait untill all commands executed. assert(ret == CL_SUCCESS); } time_swap_b.Stop(); times.push_back(time_swap_b.Duration_NS()); r.times.push_back(times); ++runs; } delete[] rndData; r.CalcAvg(); r.PrintToCSV(r.name); cout << "\n PingPong finished\n"; running = false; };