exception in imageprocessor.py

5 posts / 0 new
Last post
mohamed
exception in imageprocessor.py

when i try to simulate my code or even the standard race.py code i always get exceptions and the robot doesn't follow any track, exceptions says :

Exception in thread 1:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()

Exception in thread 3:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()

Exception in thread 4:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()

and i also get some warnings :

C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:802: RuntimeWarning: d
ivide by zero encountered in divide
adjustment = 255.0 / maximum
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:881: RuntimeWarning: d
ivide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:882: RuntimeWarning: d
ivide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:883: RuntimeWarning: d
ivide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:885: RuntimeWarning: i
nvalid value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:886: RuntimeWarning: i
nvalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:887: RuntimeWarning: i
nvalid value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB

any help ?

Images: 
mohamed
solved

it was simply solved by adding numpy.all() containing line 787

Arron Churchill
Arron Churchill's picture
Numpy and "!= None"

Put simply older versions of Numpy (like on the robots) are happy with the != None syntax which works with most other Python objects. In one of the updates they changed it so that it fails instead.

Using numpy.all() should work okay, although it does read slightly strange.

The correct replacement which has the intended behaviour in all circumstances would be:

if self.lastFrame is not None:

This way is both easier to read and should work fine in all versions of Numpy :)

Have the warnings gone now that the exceptions have been fixed?

I replace !=Non... (not verified)
Hello,

Hello,

I replace in the imageprocessor.py !=None by is not None.
I still have warning and my bot doesn't start.
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:800: RuntimeWarning: divide by zero encountered in divide
adjustment = 255.0 / maximum
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:874: RuntimeWarning: divide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:875: RuntimeWarning: divide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:876: RuntimeWarning: divide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:878: RuntimeWarning: invali value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:879: RuntimeWarning: invalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
1C:\Users\tdtran\Desktop\formulapi\ImageP
rocessor.py:880: RuntimeWarning: invali d value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB
6:11:14.959000 StartDetailedLoging()

Thanks for the helps,
Tri Duc

jtobinart
jtobinart's picture
Ignore runtime warnings

I received all the same runtime warnings every time I ran the simulator. They didn’t affect the simulator. I finally fixed them mid way through last season and there was no measurable improvement observed.

Are you trying to run the simulatorFull.py from the same computer you are running the Java simulator on? Everything worked better for me when I ran simulatorFull.py from the Pi and the Java simulator on my Mac.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.