12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /*
- * 在此方法中处理摄像头的打开、处理数据、关闭等
- * 识别到障碍物时 触发signal_camera_obstacle
- *
- */
- #include <perception/sensor_camera.h>
- void iv::perception::CameraSensor::processSensor() {
- std::cout << "camera process start" << std::endl;
- //打开激光雷达
- //障碍物识别
- iv::ObsCamera obs(new std::vector<iv::ObstacleBasic>);
- iv::ObstacleBasic t = { };
- obs->push_back(t);
- //ODS("\n\n------>thread camera: %X\n\n", GetCurrentThreadId());
- while (true) {
- srand(time(NULL));
- if (rand() % 11 == 0) {
- obs->at(0).valid = true;
- obs->at(0).nomal_x = rand() % 5;
- obs->at(0).nomal_y = rand() / 6;
- obs->at(0).nomal_z = rand() / 7;
- //signal_camera_obstacle->operator()(obs);//触发
- //std::cout << "Camera Dectected: " << obs->at(0).nomal_x << " " << obs->at(0).nomal_y << " " << obs->at(0).nomal_z << std::endl;
- }
- /*if (rand() % 9 == 0)
- break;*/
- #ifdef linux
- sleep(1);
- #endif
- #ifdef WIN32
- boost::this_thread::sleep(boost::posix_time::milliseconds(1));
- // Sleep(1000);
- #endif
- //boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
- }
- std::cout << "camera process end" << std::endl;
- }
|