# Load jpegs taken by H7+ for post-processing

**URL:** <https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672>\
**Category:** OpenMV Boards\
**Created:** [December 27, 2021, 1:19am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672 "2021-12-27T01:19:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 27, 2021, 1:19am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/1 "2021-12-27T01:19:02Z")

</div>

I need to load images that were taken with the H7+ and classified using tf.classify to re-classify them with different tflite models for simulation, diagnostics and performance comparison.

I wrote a code that scans the SD card for jpegs, loads them one by one, and runs tf.classify() on them.

However, whenever I run the code, there is a memory error. I don’t understand why because the images are generated by the H7+ itself and loaded in the same way?

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/5/529921bcc94c22b783d299ec0a56f17aa851320f.jpeg)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 27, 2021, 2:24am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/2 "2021-12-27T02:24:27Z")

</div>

Hi, don’t call dealloc extra fb. That’s to be used in a very particular way. Right now it’s just messing up our code.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 27, 2021, 2:25am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/3 "2021-12-27T02:25:39Z")

</div>

You can only call that after an alloc.

To note, we normally try to avoid exposing how memory works since we don’t have an OS. However, we do in this case. If you are planning to use it you should read the docs about how memory is partitioned.

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 27, 2021, 3:20am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/4 "2021-12-27T03:20:38Z")

</div>

The error also occurs without the dealloc extra fb line (I added it after obtaining the error, thinking it might help).  
I am confused because when the image is created by the board’s snapshot, it can be analysed with tf.classify, but when it is loaded from the card instead, it doesn’t work. So what can I do?

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [December 27, 2021, 2:27pm UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/5 "2021-12-27T14:27:46Z")

</div>

Could be an issue with the JPEG decoder… Can you post the full script ? Please use code tags.

EDIT: Actually please just attach the script, model, labels etc… in a zip file.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 27, 2021, 6:36pm UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/6 "2021-12-27T18:36:29Z")

</div>

Oh, yes, actually, it’s totally an issue with the jpeg decoder. The way this is setup right now you can’t actually read jpegs directly. You need to decode them explicitly first.

So, do

img.to\_rgb565()

This is fixed in a new version of TF I will get out before the end of the week.

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 28, 2021, 12:44am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/7 "2021-12-28T00:44:06Z")

</div>

Excellent, thank you guys for fixing this!  
I still get a “Warning: JPEG too big! Trying framebuffer transfer using fallback method!” but the script proceeds and completes just fine.

The first 2 jpegs are decoded fine but the next ones are weirdly garbled…  
 ![image](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/0/0199223a173daa609c230732b73dba6b58fbe2cc.jpeg)  
sent a PM to @kwagyeman

---

<div class="post-metadata">

**Author:** ![kurileo](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kurileo](https://forums.openmv.io/u/kurileo)\
**Post date:** [December 28, 2021, 12:53am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/8 "2021-12-28T00:53:57Z")

</div>

Is this a jpeg format file? looks like decoding failed…

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 28, 2021, 12:56am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/9 "2021-12-28T00:56:03Z")

</div>

yes the image whose screenshot I posted above is from the IDE preview after it was decoded by the board. It is the third image in a sequence of very similar images that were generated by the board. Only the first two were decoded properly. I sent a series of 6 images with the script and model to Kwabena.

---

<div class="post-metadata">

**Author:** ![kurileo](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kurileo](https://forums.openmv.io/u/kurileo)\
**Post date:** [December 28, 2021, 1:00am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/10 "2021-12-28T01:00:52Z")

</div>

That’s interesting, in my understanding, that’s almost the images in the same config? and the first two were successfully processed but the third one failed? It should be a bug…

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 28, 2021, 2:03am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/11 "2021-12-28T02:03:22Z")

</div>

Yes all images with the same config, only a few seconds difference.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 28, 2021, 7:11am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/12 "2021-12-28T07:11:33Z")

</div>

It’s a bug with Image loading and setting up the frame buffer. Jpeg decompress is fine.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 29, 2021, 3:06am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/13 "2021-12-29T03:06:32Z")

</div>

Fixed [Fix jpeg loading by kwagyeman · Pull Request #1478 · openmv/openmv · GitHub](https://github.com/openmv/openmv/pull/1478)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 29, 2021, 3:07am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/14 "2021-12-29T03:07:41Z")

</div>

The fix for being able to run TF on a jpeg image without having to convert it to RGB565 is coming soon. I got all that logic into the next release of TF with object detection. I just have to find the right version of the TF library that doesn’t crash with a segfault (Google releases code that segfaults - yes).

---

<div class="post-metadata">

**Author:** ![kurileo](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kurileo](https://forums.openmv.io/u/kurileo)\
**Post date:** [December 29, 2021, 5:51am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/15 "2021-12-29T05:51:39Z")

</div>

That’s awesome! Thanks for your hard-working XD

and for your information @darrask , could you please have a try?

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 31, 2021, 3:34am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/16 "2021-12-31T03:34:39Z")

</div>

I confirm that the jpeg loading is fixed in the durrent 4.1.5 firmware under development - it is now with proper width and height parameters - thanks!  
However, this does not allow yet to avoid using the img.to\_rgb565() conversion code - I suppose this is coming next.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 31, 2021, 3:48am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/17 "2021-12-31T03:48:09Z")

</div>

I can give you the not yet released firmware which does away with needing that.

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 31, 2021, 3:59am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/18 "2021-12-31T03:59:19Z")

</div>

Gladly - it would also help us investigate other matters!

---

<div class="post-metadata">

**Author:** ![darrask](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@darrask](https://forums.openmv.io/u/darrask)\
**Post date:** [December 31, 2021, 4:35am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/19 "2021-12-31T04:35:17Z")

</div>

I would be very glad to get the newest firmware - there are two other bugs related with JPEG loading that I hope could have been resolved already with this maybe?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 31, 2021, 4:37am UTC](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672/20 "2021-12-31T04:37:08Z")

</div>

[firmware.zip](https://forums.openmv.io/uploads/short-url/xid2XbAnjSe1gbcUwoTPpOMj477.zip) (1.1 MB)

Attached

[Next page](https://forums.openmv.io/t/load-jpegs-taken-by-h7-for-post-processing/6672.md?page=2)
