NXT-Spy – The camera images transfer now works in parallel!

So after my successful work of yesterday, I just had to code the camera image transfer today.

Si I first drew a diagram to know which classes I was going to develop and ow they were going to interact with each other:

So, the program stays idle while the Wi-Fi connection is not initialized. As soon as everything is ready, the PC’s connection class asks an image to the phone’s connection class that asks a new image to its camera and send it to the PC’s connection class. Then, the PC decodes and displays it and it loops like that again and again until one of the programs stops.

Because I already had all the elements in hand, everything came together quite easily. The only problem is that sadly but as I expected, the frame-rate is still the same : not quite satisfying yet. I did some tests and figured out that if I send a 400×240 image from the phone, it weights 144kb and I get a frame rate of 0.6 frame / sec. But if I send a 176×144 image, it weights 38.016kb and I get a frame rate of about 2 frames / sec. So exactly 1.5 bytes (12 bits) per pixel.

The only way I could perhaps enhance my frame rate would by by changing the format of the image sended by the phone.

So there seems to be two solutions to my problem :

  • The first one would be to change the format of the image being sent from the phone (for the moment it is a YUV encoded JPEG image). Event if it seems that I cannot change the YUV encoding to RGB, I can probably change the lossy compression, event if I think that JPEG is already an efficient compression.
  • The second is to simply send the images in the smallest format (176×144) and then just expand them on the computer.

So that’s it for the camera images transmission. Now the next step will be to make the Bluetooth work, it will probably be way more complicated because it is probably going to be more specific to the Android architecture than the Wi-Fi so perhaps some classes to be rewritten… I cannot work on it for the moment because my robot doesn’t have any more batteries.

Supervisor’s comment:

Well done so now all that is required is to connect the phone to the robot using Bluetooth with JCSPae.  This is non-trivial!!

Leave a Reply

Your email address will not be published. Required fields are marked *