OSError File Corrupted?

So uhm… I got an error saying "OSError: File Corrupted…

Untitled picture

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()

class Detection:
    def __init__(self):
        self.img = sensor.snapshot()
        self.H = image.Image("/H.png")
        self.S = image.Image("/S.png")
        self.U = image.Image("/U.png")

    def HSU(self):
        self.harmed = image.find_template(template=self.H, threshold=0.5, search=image.SEARCH_EX)
        if self.harmed:
            rect.draw_rectangle(self.harmed, thickness=1)
        self.safe = image.find_template(template=self.S, threshold=0.5, search=image.SEARCH_EX)
        if self.safe:
            rect.draw_rectangle(self.safe, thickness=1)
        self.unharmed = image.find_template(template=self.U, threshold=0.5, search=image.SEARCH_EX)
        if self.unharmed:
            rect.draw_rectangle(self.unharmed, thickness=1)

    def send(self):

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
OS: Windows

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.


HSU.zip (20.5 KB)

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/
[HSU]$ ls
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