So uhm… I got an error saying "OSError: File Corrupted…
Now, I got the error after I included the self argument in the init method and now I have no idea how I’m supposed to solve this.
Here’s my code if anyone is curious:
import sensor, time, image
#initialization of the camera, resolution: 160, 120
sensor.skip_frames(time = 2000)
clock = time.clock()
self.img = sensor.snapshot()
self.H = image.Image("/H.png")
self.S = image.Image("/S.png")
self.U = image.Image("/U.png")
self.harmed = image.find_template(template=self.H, threshold=0.5, search=image.SEARCH_EX)
self.safe = image.find_template(template=self.S, threshold=0.5, search=image.SEARCH_EX)
self.unharmed = image.find_template(template=self.U, threshold=0.5, search=image.SEARCH_EX)
detection = Detection()
We don’t support png images.
Is JPG supported? I got the same issue from jpg.
Yes JPEG images are support. Since no one else has reported this I’d ask you to double check the files, make sure they’re not getting corrupted when copied, run the script from the IDE to see which line exactly fails, and if it’s still not working then post all the details (fw version, cam version, os) and attach the image files.
I’m already running the script from the IDE, failure is at line 14, the init method but the pictures open on photo viewer just fine.
Board: H7 with OV7725 camera
Also, since I haven’t attached the camera to the robot yet, I haven’t had a chance to actually test the code outside the IDE. And the new users can only post 1 media file is annoying ;-;
Try to post again and attach all 3 images as a zip file.
It says new users cannot post attachments…
I’ve upped your trust level, please try again.
These are png files. Please compress the JPEG images that you said failed to load, in a zip file and attach that.
These are PNG images renamed to JPG. I’ll assume this is just a mistake, either way, you can’t use compressed images for templates. The template needs to be a small grayscale PGM image (ex 32x32 pgm).
[tmp]$ cd HSU/
H.jpg S.jpg U.jpg
[HSU]$ identify *jpg
H.jpg PNG 128x126 128x126+0+0 8-bit sRGB 2700B 0.000u 0:00.000
S.jpg PNG 122x126 122x126+0+0 8-bit sRGB 11310B 0.000u 0:00.000
U.jpg PNG 132x128 132x128+0+0 8-bit sRGB 6882B 0.000u 0:00.000