Welcome, Guest. Please login or register.
Did you miss your activation email?

Username: Password:


Pages: [1]   Go Down

Author Topic: Read Images From SD card  (Read 4937 times)

Crycek

  • Leaving the nest
  • * Posts: 8
  • Male
Read Images From SD card
« on: November 23, 2011, 03:41:03 PM »

Hi everyone, first post,
 I am a teaching assistant for a new class that is going to use Pleo rb's for student laboratories. So we have 25 of them!

 Has anyone been able to load RGB data into a variable after saving an image to the SD card or internal flash? I have seen lots of posts about saving images but none on actually reading the images. Is the file too large to be read into memory?

 Also double checking but it seems that there is no way to get Pleo monitor working on windows 7 64 bit since the computer wont recognize the Pleo rb, since the driver is 32 bit. Is this still the case? No option of using an emulator or other operating system because that is what the school's lab computers are running.   
Logged


RedwoodsMama

  • Pleo Grand Master, 4th epoch
  • **** Posts: 4875
  • us Female
  • Pleo(s): Nova, Major Tom, Argyle the blind Pleo, Baby Ruth, Chester, and 22 more Pleos
  • : 2013 winner2010 winnerTomato Harvest Festivals
    • Mary_Ann
    • Silvester
    • none
    • Flying_Ace
Re: Read Images From SD card
« Reply #1 on: November 23, 2011, 03:57:46 PM »

Wow, 25, sounds like fun, I have 17 that work. Sudents should have lots of fun, if you can get them to work with the computer. Unfortunatly, this is not up my alley, but  I would love to see if anyone has the answer to this question, It could make for some very interesting studies. What in particular do you hope to do with the Pleos in your study, work? If you could upload photos, or videos that would be fun for the rest of us. I am thinking perhaps degers, M. Weed or even IMR or Crewella may know the answer to this one. I am dying to see what happens next. Welcome to the forums. Have you used Pleos out of the classroom and are these the older 2007 Ugobe Pleos?
                                                      RWM
Logged
Animals are SOUL Too, Be kind to all those who live on this planet with us.

InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Read Images From SD card
« Reply #2 on: November 23, 2011, 04:57:36 PM »

Sorry I don't know enough about programming to answer that either but I would suggest downloading the PDK (Pleo developers kit) from Pleoworld.com.hk for a starter. Pleopet is highly knowledgable about the inner workings of Pleo so if they drop in that would be helpful. You'll also want MySkit and Dinomite.

Have you tried running the emulator in compatibility mode?
Logged
Eagerly awaiting Vector and Blue!

PleoPet

  • Pleontologist
  • * Posts: 162
  • Female
Re: Read Images From SD card
« Reply #3 on: November 24, 2011, 11:24:57 AM »

> Has anyone been able to load RGB data into a variable after saving an image to the SD card or internal flash? I have seen lots of posts about saving images but none on actually reading the images. Is the file too large to be read into memory?

The Pleo PDK has an API to capture the image and store it in a file (in the internal Data Flash or the SD card). See "camera_take_picture()"

If you want to process that image data you will hit several problems.
First of all there is very little RAM for Pawn programs. For the main program, the limit is 4KB for the header, stack, global data, and the largest code module combined. Try to limit yourself to around 1KB of global data. That is not a typo Kilobytes not MegaBytes.
You can load in the file piece by piece and process it in smaller chunks. This is slow because of file reading, and relatively slow Pawn execution speed. This does not take into account the time taken to capture the image.

What are you trying to do?

There are other APIs for the most common features: camera_request_average and camera_get_average to get an average RGB value for a rectangle in the image, or the color tracking features.
They are written in native code, not Pawn of course.

Logged

Crycek

  • Leaving the nest
  • * Posts: 8
  • Male
Re: Read Images From SD card
« Reply #4 on: November 24, 2011, 12:57:07 PM »

Thanks for the replies! I will definitely have pics and videos of the students lab to post next term.

I have been using the latest PrbDK, and we have MySkit but so far we are probably just going to use the motions that come with the development kit. I haven't tried Dinomite yet, does it work with the rb units? On windows 7 64 bit?

I thought the RAM was the limiting factor. We were hoping to give the students some hands on time doing some very simple image analysis, like identifying colors by analyzing pixels, but I guess that will have to be taught in the lectures and the lab will use the built in APIs.

Does anyone have example code for camera_request_average and camera_get_average? It would be really helpful.
« Last Edit: November 24, 2011, 01:00:56 PM by Crycek »
Logged

PleoPet

  • Pleontologist
  • * Posts: 162
  • Female
Re: Read Images From SD card
« Reply #5 on: November 25, 2011, 10:54:46 AM »

> I have been using the latest PrbDK, and we have MySkit but so far we are probably just going to use the motions that come with the development kit.
The PDK has very few motions (around 30). For basic robot control, walking biting etc, that may be enough. For more complicated personalities, you can either design them from scratch with MySkit, or steal them from the built in personality (around 800 of them).

> I haven't tried Dinomite yet, does it work with the rb units? On windows 7 64 bit?
> I thought the RAM was the limiting factor... but I guess that will have to be taught in the lectures and the lab will use the built in APIs.
IMHO: Pleo RB is not a very good robot for programming. In fact I find the older Pleos are better.
With the old models, the regular sized SD card was much easier to swap, and you could connect the USB cable directly, or even better you could connect to the RS-232 style serial connector (better than the USB for debugging)

With the Pleo RB the USB cable is in the bottom of the battery compartment. You need to rig up a special adapter to connect the battery.
Then there is the problem with Windows 7 drivers. I believe it is mostly a 64-bit driver issue.

What hardware setup (cable / battery) are you using to connect the Pleo RB to the computer?

> Does anyone have example code for camera_request_average and camera_get_average? It would be really helpful.

Here's something reworked from the default personality (no longer used in the color tracking tricks)
Code: [Select]
// call request with the rectangle upper_left_x/y to lower_right_x/y

    camera_request_average(upper_left_x, upper_left_y, lower_right_x, lower_right_y);
    kill_time(2); // wait 2 ms minimum

    new int: average_r;
    new int: average_g;
    new int: average_b;

    // wait for camera to get average, with timeout if it takes too long
    new start = time()
    while (!camera_get_average(average_g, average_b, average_r))
    {
        yield(); // optional

        if (time() - start > timeout_value)
        {
            // camera is not responding
            //  experiment to find best timeout_value
            average_r = 0;
            average_g = 0;
            average_b = 0;
            break;
        }
    }

    // do something with average_r/g/b
}

WHERE:
static kill_time(int: ms)
{
    new start = time();
    while (time() - start < ms)
    {
        // yield();
    }
}


Logged

Crycek

  • Leaving the nest
  • * Posts: 8
  • Male
Re: Read Images From SD card
« Reply #6 on: November 25, 2011, 03:07:48 PM »

Thanks so much for the sample code. That helps a lot.

Do you know the limits for the upper and lower x and y values for the window, if not I will just play around with them?

I am currently working by connecting the Pleo rb to a computer with the usb cable and using a power supply for power.
Logged

Crycek

  • Leaving the nest
  • * Posts: 8
  • Male
Re: Read Images From SD card
« Reply #7 on: December 02, 2011, 03:28:41 PM »

I finally got a chance to try that code on the Pleo rb, but I hasn't worked yet, any idea on the timeout_value or rectangle values?
Logged

PleoPet

  • Pleontologist
  • * Posts: 162
  • Female
Re: Read Images From SD card
« Reply #8 on: December 04, 2011, 12:13:45 PM »

> any idea on the timeout_value or rectangle values?
From the old test program (pre-RB), the timeout they use is 200 (ms) and the rectangle values are anywhere in the image. The image is 176x144 pixels.

> I finally got a chance to try that code on the Pleo rb, but I hasn't worked yet...

HOWEVER, I tried my test program using the code provided. It works fine on the old Pleos, but fails on the PleoRB (running the latest 1.0 firmware)
It looks like they broke the 'camera_request/get_average APIs for the RB, or it requires additional initialization or tricks that the old Pleo doesn't.
The current PleoRB personality does not rely on this API. It was used a lot in the older Pleo personalities.

Disappointingly, this is in the closed source portion of the ARM firmware. If it was in the Pawn code, I can usually patch it.
You can try reporting it as a bug to Innvo, but I wouldn't hold your breath.
Logged
Pages: [1]   Go Up
 

SimplePortal 2.3.5 © 2008-2012, SimplePortal