Bob the Pleo Forums

Pleo Stuff => Pleo Hardware/Software => PDK, Programming, and code => Topic started by: Dca on May 10, 2012, 08:00:02 AM

Title: Take picture with camera of Pleo rb
Post by: Dca on May 10, 2012, 08:00:02 AM
Hi all,
i need your help.
How can i program that my Pleo rb takes a picture with his camera and save it to the SD-Card.
I've tried to take a picture after a touch of his head. So in the sensor.p file:
        case SENSOR_HEAD:
        {
             new file_name[] = "samplefile";
      camera_take_picture(file_name);
         }
But it doesn't work.


Title: Re: Take picture with camera of Pleo rb
Post by: PleoPet on May 10, 2012, 03:26:22 PM
Several comments:

"camera_take_picture" returns a boolean result, it should be checked.

Unfortunately "camera_take_picture" only starts the process of taking and saving a picture. It is a slow process, and you need to keep checking a special (undocumented) property to see when it is done.

Also, be careful with strings stored as data. Unless you need data in a variable, use a literal string. Otherwise it wastes valuable RAM. Also be sure you have "#pragma pack 1" near the start of the source file.

Here is some code I use in my test program:

Code: [Select]
#include "Camera.inc"

//IF NEEDED
native bool: camera_take_picture(const file_name[]);
 // some versions of SDK do not have it in Camera.inc

#pragma pack 1

...
   // save the picture
    if (camera_take_picture("A:one.img")) // save on SD card
    {
        PlaySound(snd_cap_one); // shutter sound
        // wait until done saving
        while (get(property_cam_img_progress) != 0)
        {
            yield();
        }
        // now the picture is saved
        PlaySound(snd_camera_saved);
    }
    else
    {
        PlaySound(snd_capture_error);
    }

Title: Re: Take picture with camera of Pleo rb
Post by: Dca on May 13, 2012, 03:19:56 AM
Thank you very much for your answer.
Title: Re: Take picture with camera of Pleo rb
Post by: GreatestCaution on June 27, 2012, 12:25:41 PM
Thank you very much for your answer.

Hello guys!
Sorry Dca, You try it? it works?

Can upload the archive sensor.p completely, Dca or PleoPet?

Thank You!
Title: Re: Take picture with camera of Pleo rb
Post by: GreatestCaution on July 19, 2012, 07:52:03 AM
Hello,

I trying your code and the more strange is that code runs once of ten.
It's extremly strange, something occure about "while", don't reproduce me "camera_saved".


while (get(property_cam_img_progress) != 0)
        {
            yield();
        }
        // now the picture is saved
        PlaySound(snd_camera_saved);

Any idea??

Thanks.
Title: Re: Take picture with camera of Pleo rb
Post by: lordlacky on July 30, 2014, 10:44:13 AM
hi,
i know it is an old thread but i have the same problem like GreatestCaution. the problem is that the code dont work every time. but i dont know why :/
have anybody a solution?
Title: Re: Take picture with camera of Pleo rb
Post by: kat on July 30, 2014, 05:01:55 PM
I don't know if there is anyone around on the forums any more who attempts pleo programming.  All I can suggest is maybe send PleoPet a personal message and see if she can help you out. 
Title: Re: Take picture with camera of Pleo rb
Post by: Echo538 on July 31, 2014, 12:09:34 AM
Wait... Pleo RB can take pictures? Does it need a micro sd card? How much does one cost, anyway?
Title: Re: Take picture with camera of Pleo rb
Post by: lordlacky on July 31, 2014, 04:52:18 AM
Yes PleoRb can take pictures. And now my Code works fine, i have some Problems which i don't understand, but i need some one who know about programming the pleo.

Sorry that my Questions on two diffrent forums, but maybe i can find somebody that can help me.

@Echo538
my micro sd-card costs about 8 € and is 4 GB, but you must try the micro sd-card, because the recommendation is for a card less than 2 GB.
And the pictures are very very low quality

Here is one
(http://picload.org/image/lwodlcp/img.png)
Title: Re: Take picture with camera of Pleo rb
Post by: InmemoryofRomeo on July 31, 2014, 05:24:02 AM
Sadly as Kat said, there are no programmers here anymore. Pleopet is your best bet, many of those who posted here are no longer active members. Good luck, do share if you find out anything.
SimplePortal 2.3.5 © 2008-2012, SimplePortal