*~ Take picture with camera of Pleo rb ~*
Pages: [1]   Go Down
  Print  
Author Topic: Take picture with camera of Pleo rb  (Read 853 times)
0 Members and 1 Guest are viewing this topic.
Dca

Hatchling
Posts: 2
Germany   Male

« 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.


Logged
PleoPet

Full Member
* Posts: 161
United States   Female

« Reply #1 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:
#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);
    }

« Last Edit: May 10, 2012, 03:36:00 PM by PleoPet » Logged
Dca

Hatchling
Posts: 2
Germany   Male

« Reply #2 on: May 13, 2012, 03:19:56 AM »

Thank you very much for your answer.
Logged
GreatestCaution

Member
* Posts: 7
Spain   Male
Pleo(s): Dino

« Reply #3 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!
Logged
GreatestCaution

Member
* Posts: 7
Spain   Male
Pleo(s): Dino

« Reply #4 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.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  





Login with username, password and session length

Pleo Quote: In theory, there is no difference between theory and practice; In practice, there is. -- Dr. Mel
SimplePortal 2.3.2 © 2008-2010, SimplePortal