jwatte / donkey_racing

Tools to help train for the Donkey Car machine learning racing
MIT License
14 stars 8 forks source link

OpenCV - calibrate_camera functionality #1

Open filmo opened 6 years ago

filmo commented 6 years ago

Hi,

I'm trying to run the code in 'calibrate_camera'

When I do so, I am getting the following error on my 'stock' donkey car install:

(dk) pi@d2:~/donkey_racing/calibrate_camera $ python capture_images.py
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey, file /home/pi/opencv-3.3.0/modules/highgui/src/window.cpp, line 676
Traceback (most recent call last):
  File "capture_images.py", line 9, in <module>
    cv2.waitKey(1)
cv2.error: /home/pi/opencv-3.3.0/modules/highgui/src/window.cpp:676: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvWaitKey

I ran the install.sh script on the donkey's raspberry pi, but am still getting the error.

In order to use your calibration code, do I need to recompile OpenCV on the donkeycar pi to fix this error? or am I doing something else wrong/neglected a step?

jwatte commented 6 years ago

You need a desktop/gui installed on the Pi, and started, if you haven't. If it still doesn't work, then the opencv library you have is built without GUI support.

filmo commented 6 years ago

Thanks. That has helped. From the GUI desktop on the Pi, in a Terminal window I now run:

./capture_image.py

After a couple seconds I then get:

pi@d2:~/donkey_racing/calibrate_camera $ ./capture_images.py 
press a key for each picture (or wait 3 seconds)
Traceback (most recent call last):
  File "./capture_images.py", line 13, in <module>
    with capture.Capture() as c:
AttributeError: Capture instance has no attribute '__exit__' 

I'm using whatever install of openCV came with the default donkeycar installation. Did you compile openCV yourself or are you also using what came with the stock install? (I did run the install.sh script in your repository, so that may have altered the stock version??)

Thanks for your help.