Thunderborg + Line following

Is it possible to use MonsterBorg Self-drive for a line that is approximately 16 -18 mm wide? If not are there any other alternatives?

Many Thanks

Is it possible to use MonsterBorg Self-drive for a line that is approximately 16 -18 mm wide? If not are there any other alternatives?

Many Thanks

piborg's picture

As long as the line can be clearly seen by the camera then the self-drive code should work fine.

When I launched the auto-drive script it gave me the error that OpenCv2 module was not found. I tried to fix it by changing the lines to:
Settings.capture.set(cv2.CV_CAP_PROP_FRAME_WIDTH, Settings.imageWidth);
Settings.capture.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, Settings.imageHeight);
Settings.capture.set(cv2.CV_CAP_PROP_FPS, Settings.frameRate);

However, this did not work. How could fix this problem? In addition, how do I set up X11 forwarding (on a mac) for this script as well?

Many Thanks!

piborg's picture

Can you attach the actual error message :)

This might help with the X11 forwarding: https://raspberrypi.stackexchange.com/questions/36343/how-can-you-ssh-in...

It says 'No module named cv2' . I was not fully sure if I have installed open_cv2 correctly. What is the terminal command to install opencv2?

Many Thanks

piborg's picture

That error means that OpenCV is not setup.

You can install OpenCV with the following commands

sudo apt-get update
sudo apt-get -y install libopencv-dev python-opencv

Once I do this, should I change the lines:

Settings.capture.set(cv2.CV_CAP_PROP_FRAME_WIDTH, Settings.imageWidth);
Settings.capture.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, Settings.imageHeight);
Settings.capture.set(cv2.CV_CAP_PROP_FPS, Settings.frameRate);

back to the original?

Many thanks for your help!

piborg's picture

You might need to change them. I think these ones work with the latest version:

Settings.capture.set(cv2.CAP_PROP_FRAME_WIDTH, Settings.imageWidth);
Settings.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, Settings.imageHeight);
Settings.capture.set(cv2.CAP_PROP_FPS, Settings.frameRate);

I got an error:
Unable to init server: Could not connect: Connection refused

(Monster view:1976): Gtk-WARNING **: 20:28:03.674: cannot open display:
Could you explain how to fix it please?
Many Thanks!

piborg's picture

That GTK error means that the script is unable to display the GUI window.

You will either need to enable X11 forwarding over SSH or use a VNC connection to the Raspberry Pi instead.

Hello, I am also facing similar issues. When I run the script this error code appears:
(, ValueError('The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()',),

Please could you explain how to fix this?

piborg's picture

In MonsterAuto.py look for the line:

if monsterView != None:

and change it to

if monsterView is not None:

Hello, I made all the changes outlined above, yet I got this error message:

IDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy
Traceback (most recent call last):
File "./MonsterAuto.py", line 95, in
Settings.capture.open()
TypeError: Required argument 'filename' (pos 1) not found

Could you please explain what is going wrong here?
Many Thanks!

piborg's picture

I have not seen that error before...

My first suggestion would be to go to the Raspberry Pi configuration and check that the camera is still enabled. Make sure nothing is trying to talk to the camera when the Pi starts, then restart and see if the problem is still there.

If that does not help there is a discussion about this error on the Raspberry Pi forum: https://www.raspberrypi.org/forums/viewtopic.php?t=203608
One person suggested the following work-around. Look for this line:

Settings.capture = cv2.VideoCapture(0) 

and add these two lines directly after it:

 
Settings.capture.release()
Settings.capture = cv2.VideoCapture(0) 

This will connect to the camera, then immediately disconnect and reconnect. It worked for them, so it might help.

Subscribe to Comments for "Thunderborg + Line following"