Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

input.cpp 803B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "input.h"
  2. Input::Input(/* args */)
  3. {
  4. }
  5. Input::~Input()
  6. {
  7. }
  8. Mat Input::readFile(String filePath)
  9. {
  10. Mat image = imread(filePath, IMREAD_COLOR);
  11. if(image.empty())
  12. {
  13. std::cout << "Could not read the image: " << filePath << std::endl;
  14. return Mat();
  15. //To do:Exception handeling
  16. }
  17. imshow("Display window", image);
  18. waitKey(0);
  19. return image;
  20. }
  21. Mat Input::readWebcam()
  22. {
  23. const int VID_HEIGHT = 240;
  24. const int VID_WIDTH = 320;
  25. Mat image;
  26. VideoCapture cap(0);
  27. cap.set(CAP_PROP_FRAME_HEIGHT, VID_HEIGHT);
  28. cap.set(CAP_PROP_FRAME_WIDTH, VID_WIDTH);
  29. if(!cap.isOpened()) {
  30. cout << "Fehler";
  31. return Mat();
  32. }
  33. cap.read(image);
  34. imshow("Display window", image);
  35. waitKey(0);
  36. return image;
  37. }