int main() { VideoCapture webcam(3); Mat frame; webcam.set(CV_CAP_PROP_FRAME_WIDTH, height); webcam.set(CV_CAP_PROP_FRAME_HEIGHT, width); if (serialPort.connect("//dev//ttymxc3")==0) { cout << "Can't open serial port" << endl; return -1; } while(true) { timer.reset(); webcam.read(frame); cv::blur( frame, frame, Size(4,4) ); imshow("Blured",frame); Mat frame_can = Mat::zeros( frame.size(), CV_8UC3 ); cv::Canny( frame, frame_can, 50, 200, 3 ); detect_lines(frame_can, frame, "Canny"); waitKey(5); cout << "Timer: " << timer.elapsed() << endl; } return 0; }
/// <summary> /// Entry point for the application /// </summary> /// <param name="hInstance">handle to the application instance</param> /// <param name="hPrevInstance">always 0</param> /// <param name="lpCmdLine">command line arguments</param> /// <param name="nCmdShow">whether to display minimized, maximized, or normally</param> /// <returns>status</returns> int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { port1.connect(L"\\\\.\\COM17"); port2.connect2(L"\\\\.\\COM21"); //neu CSkeletonBasics application; application.Run(hInstance, nCmdShow); }
int main() { Dualshock3 joystick; joystick.connect(); int err=serialPort.connect("//dev//ttyACM0"); send_command('n', 0); while( 1 ) /* infinite loop */ { joystick.getData(); if (joystick.button[16]){ serialPort.disconnect(); close( joy_fd ); system("sixad --stop &"); exit(0); } joystick.getData(); // Detect conflits and process input if (joystick.axis[12] != 0 && joystick.axis[13] != 0){ // Rumbleeeeeee send_command('n', 0); }else if (joystick.axis[12] == 0 && joystick.axis[13] != 0){ //input_processing(FWD, joystick.axis[13]); cout << "frente" << endl; send_command('f', joystick.axis[12]/547); }else if(joystick.axis[12] != 0 && joystick.axis[13] == 0){ //input_processing(BCK, joystick.axis[12]); send_command('b', joystick.axis[13]/547); }else{ send_command('n', 0); } joystick.getData(); if (joystick.axis[0] > 0){ send_command('r', joystick.axis[0]); }else if(joystick.axis[0] < 0){ send_command('l', abs(joystick.axis[0])); }else{ send_command('l', 0); } } serialPort.disconnect(); close( joy_fd ); /* too bad we never get here */ return 0; }
int main() { cout << "AX Control starts" << endl; // prints AX Control int error=0; int idAX12=0; SerialPort serialPort; if (serialPort.connect("/dev/ttyUSB0")!=0) { printf ("Serial port opened\n"); // Sync Write: 0xFF 0xFF 0xFE(broadcast) [(L+1) * N + 4] 0x83(instruction) 0x20(location) 0x02(lenght of the data) 0x01(id1) lowvel1 hivel1 0x02(id2) lowvel2 hivel2 chk // This one sends vels to both motors with orientation sendVels(1,512,1, 2,512,0, &serialPort); serialPort.disconnect(); } else { printf ("nCan't open serial port"); error=-1; } cout << endl << "AX Control ends" << endl; // prints AX Control return error; }
int main() { Gamepad gpad(0); SerialPort serial; Sleep(1000); serial.connect("\\\\.\\COM11"); while (true) { gpad.update(); float lx = scaleInput(gpad.getStickLeftX()); float ly = scaleInput(gpad.getStickLeftY()); float rx = scaleInput(gpad.getStickRightX()); float ry = scaleInput(gpad.getStickRightY()); printf("lx = %f ly =%f rx = %f ry = %f\n", lx, ly, rx, ry); int16_t v[2]; v[0] = ly * 255; v[1] = ry * 255; int ret = serial.WriteData((char*)v, 4); Sleep(20); } }