I'm working on a project right now that involves trying to get an Adalogger Feather M0 to count bugs in a trap (I know its not the right board to do anything close to image recognition but its what my professor is insisting I work with). The setup I'm working with right now involves a camera taking pictures and placing them as JPG images on a microSD. I've been trying to get a number of different JPG decoder libraries to be able to load the image into an array that I can work with but they seem to be aimed at loading the images straight onto displays. I figure there is probably a simple solution but I just haven't found it yet so I'm asking for help. I should also note that due to RAM limitations I'm going to have to process the image in pieces so I need to find a way to load just portions of the image at a time.
You should look closer. It is a good bet, they buffer the image in memory before writing it to the display.
Also if you have an SD card, you can open a file and use that to store the uncompressed image.
Here's another thing - please don't mention things peripherally and expect the information to be useful to helpers on this forum. Whenever you make a statement like this, be specific. In this case, tell us which libraries and why exactly each one is unsuitable. Or, at least, choose the most promising one and explain it.
Or:
due to RAM limitations
such as, exactly?...
Sorry about that, I'm pretty new to this kind of thing. I've tried to use JPEGDEC, JPEGDecoder, and Tjpg_Decoder. The RAM limitations weren't really relevant to this post so I didn't explain further but The images are 640x480 and the Adalogger only has 48kb of RAM so uncompressed the image would be way too big to load all at once. I'm a fairly unseasoned coder so I'm probably just not understanding how the decoder libraries work.
Links please?
Thanks, that is helpful. As far as I know, the JPEG protocol does not require full buffering, it can be read and processed in smaller chunks, but not a single line at a time (due to the cosine matrix transforms it uses).
Yeah, it's in the 8x8 MCUs. I think if I could even just decode the whole thing and store the uncompressed image in the microSD that might work to just pull from.
It also depends on the requirements of the post processing you plan to do. Can that be done serially? If you can write it to a file, it's probably the easiest way...
Yeah, that's pretty much what I'm trying to figure out how to do. The postprocessing is just going to be doing a little color thresholding and some dilation and erosion to isolate the bugs and count them. I'll be fine with that though, right now I'm just stuck because I haven't figured out how to get access to the data
Obviously, it would take some digging, but I think there might be functions/methods in the first library you posted that could be pressed into service. You would have to make your own sketch that omits all the display stuff.
hmm ok, I'll look into it again, thanks for the help
Cross post with Partial Image Analysis - #21
I'm working on some similar stuff right now but I'm stuck trying to figure out how to load a JPG into an array that I can work with in Arduino. How have you gone about it? Most of the libraries I've found seemed designed to load the image straight onto a display and I haven't figured out how to just put it into an array (or more realistically put just part of it into an array at a time)
FIRST, you have to decode the JPEG image so you can look at the pixels.
I guess that doesn't seem clear in my first comment. I understand but I just haven't been able to figure out if/how the jpeg decoding libraries are able to load an array or if they can only send it straight to a display. Here's a link to the post I just made (Importing JPG to an Array on Arduino)
The display is their array. Otherwise you will have to store and accumulate the partial image in some mass storage device until the decode is complete.
That makes sense, so in this case, is there a way to just have the decoder send data straight to an array that I can work with instead?
Very probably, but you may have to hack the library. Image files are large compared to the memory of basic Arduinos, so it it was probably undesirable to use an array when the library was written. Now there are plenty of options with way more RAM - you may want to look for code that would do the job on a PC and recompile it for your device.
@mrw4554,
I have removed your question and replies that you put on the end of someone else's topic and added them here. You have hijacked another topic with your own question then started a new topic on the same subject. Both hijacking and duplicate topics are against the forum rules as they mess up the forum and waste the time of the people trying to help you. Any more will result in a ban from posting. Please read the forum rules: How to get the best out of this forum
Thank you.