saving color images is very slow

Discussions about the AI-deck
Post Reply
noah2021
Beginner
Posts: 16
Joined: Thu Oct 07, 2021 8:48 pm

saving color images is very slow

Post by noah2021 »

Hi, I bought a color camera for my AI deck 1.1. I found it's very slow to save color images. So, each image (.ppm) takes about 30 seconds. I ran the code by 'make run' on the RAM. The WIFI (hotspot) is the default one generated by the deck.

Thanks!
Last edited by noah2021 on Tue Nov 16, 2021 9:22 am, edited 2 times in total.
gemenerik
Beginner
Posts: 19
Joined: Wed Apr 07, 2021 11:11 am

Re: saving color images is very slow

Post by gemenerik »

noah2021 wrote: Thu Nov 11, 2021 9:23 pm Hi, I bought a color camera for my AI deck 1.1. I found it's very slow to save color images. So, each image (.ppm) takes about 30 seconds. I ran the code by 'make run' on the RAM. The WIFI (hotspot) is the default one generated by the deck.

Thanks!
Hi Noah!

Can you elaborate on what you want to achieve and what you have tried? I'll try my best to answer though.

I assume you are calling the WriteImageToFile function from the default gaplib ImgIO? This writes an image to your computer over JTAG. It being slow is expected behavior. I wouldn't expect a huge performance difference, but there may be some ways to speed it up:
The simplest thing you can do is look at bumping up the OpenOCD adapter speed to the maximum speed supported by your JTAG adapter. You are looking for the setting "adapter speed xxxx". I think it should be possible to set this by adding a line in your adapter's .cfg file in the GAP SDK.
Otherwise you can look at optimizing the function/protocol of the file transfer for speed. This may be a bit more tricky and I couldn't tell you whether or not it is at all possible to improve.

Alternatively you can stream the images via the NINA, look at the WiFi streamer example. There is currently no default support for "saving" images, but with some minor changes to "viewer.py" you can do this. Note however that the received images are JPEG compressed.
noah2021
Beginner
Posts: 16
Joined: Thu Oct 07, 2021 8:48 pm

Re: saving color images is very slow

Post by noah2021 »

gemenerik wrote: Mon Nov 15, 2021 11:00 am
noah2021 wrote: Thu Nov 11, 2021 9:23 pm Hi, I bought a color camera for my AI deck 1.1. I found it's very slow to save color images. So, each image (.ppm) takes about 30 seconds. I ran the code by 'make run' on the RAM. The WIFI (hotspot) is the default one generated by the deck.

Thanks!
Hi Noah!

Can you elaborate on what you want to achieve and what you have tried? I'll try my best to answer though.

I assume you are calling the WriteImageToFile function from the default gaplib ImgIO? This writes an image to your computer over JTAG. It being slow is expected behavior. I wouldn't expect a huge performance difference, but there may be some ways to speed it up:
The simplest thing you can do is look at bumping up the OpenOCD adapter speed to the maximum speed supported by your JTAG adapter. You are looking for the setting "adapter speed xxxx". I think it should be possible to set this by adding a line in your adapter's .cfg file in the GAP SDK.
Otherwise you can look at optimizing the function/protocol of the file transfer for speed. This may be a bit more tricky and I couldn't tell you whether or not it is at all possible to improve.

Alternatively you can stream the images via the NINA, look at the WiFi streamer example. There is currently no default support for "saving" images, but with some minor changes to "viewer.py" you can do this. Note however that the received images are JPEG compressed.

Hi @gemenerik, thanks for your reply.

I didn't use the JTAG. I only used the Crazyradio and I ran the AIdeck_examples/GAP8/test_functionalities/test_camera/test.c

line 158
#ifdef COLOR_IMAGE
WriteImageToFile("../../../img_color.ppm", WIDTH, HEIGHT, sizeof(uint32_t), buff_demosaick, RGB888_IO);

The code is the official test camera code provided by Bitcraze. And I noticed it saves the image line by line as follows.
Initialized buffers
Writing image [# ]
Writing image [# ]
Writing image [## ]
Writing image [### ]
Writing image [#### ]
......

Do you know how to improve it?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: saving color images is very slow

Post by kimberly »

Hi!

This write image to file will only work with the jtag programmer, so not sure where it is saving the image now.... It should actually give a fault.

In the case that you are using a jtag cable, there is from the aideck examples repository no way to increase this, except for saving smaller images. The color image has 3 times more bytes than a grayscale image, so it takes 3 times as long.

This WriteImageToFile is a function that comes directly from the GAP8 sdk of which we do not have direct control over. You would need to put in an issue at the github repository of the gap8 SDK if you have questions about this function.
noah2021
Beginner
Posts: 16
Joined: Thu Oct 07, 2021 8:48 pm

Re: saving color images is very slow

Post by noah2021 »

kimberly wrote: Mon Nov 15, 2021 5:35 pm Hi!

This write image to file will only work with the jtag programmer, so not sure where it is saving the image now.... It should actually give a fault.

In the case that you are using a jtag cable, there is from the aideck examples repository no way to increase this, except for saving smaller images. The color image has 3 times more bytes than a grayscale image, so it takes 3 times as long.

This WriteImageToFile is a function that comes directly from the GAP8 sdk of which we do not have direct control over. You would need to put in an issue at the github repository of the gap8 SDK if you have questions about this function.
Hi, thank you. Yes, you are correct. I was using the JTAG.

OK, so now I'm wondering how can I save the color image in viewer.py when I use the CrazyRadio wifi? Do I need to implement my own demosaicing algorithm in the viewer.py? Thank you.
gemenerik
Beginner
Posts: 19
Joined: Wed Apr 07, 2021 11:11 am

Re: How to save color images when using Crazyradio

Post by gemenerik »

Hi Noah,

Can you undo the edits to the first post, change the thread title back to the old, and open a new thread regarding the color image saving from the streamer? This helps keep the threads clean and easy to follow for everyone. Check out the forum rules.

The tips Kimberly and I gave for speeding up the image saving over JTAG still stand.
Post Reply