impl_camera.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * 在此方法中处理摄像头的打开、处理数据、关闭等
  3. * 识别到障碍物时 触发signal_camera_obstacle
  4. *
  5. */
  6. #include <perception/sensor_camera.h>
  7. void iv::perception::CameraSensor::processSensor() {
  8. std::cout << "camera process start" << std::endl;
  9. //打开激光雷达
  10. //障碍物识别
  11. iv::ObsCamera obs(new std::vector<iv::ObstacleBasic>);
  12. iv::ObstacleBasic t = { };
  13. obs->push_back(t);
  14. //ODS("\n\n------>thread camera: %X\n\n", GetCurrentThreadId());
  15. while (true) {
  16. srand(time(NULL));
  17. if (rand() % 11 == 0) {
  18. obs->at(0).valid = true;
  19. obs->at(0).nomal_x = rand() % 5;
  20. obs->at(0).nomal_y = rand() / 6;
  21. obs->at(0).nomal_z = rand() / 7;
  22. //signal_camera_obstacle->operator()(obs);//触发
  23. //std::cout << "Camera Dectected: " << obs->at(0).nomal_x << " " << obs->at(0).nomal_y << " " << obs->at(0).nomal_z << std::endl;
  24. }
  25. /*if (rand() % 9 == 0)
  26. break;*/
  27. #ifdef linux
  28. sleep(1);
  29. #endif
  30. #ifdef WIN32
  31. boost::this_thread::sleep(boost::posix_time::milliseconds(1));
  32. // Sleep(1000);
  33. #endif
  34. //boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
  35. }
  36. std::cout << "camera process end" << std::endl;
  37. }