How to capture Photograph in cspro

Discussions about CSEntry
manojorb

How to capture Photograph in cspro

Postby manojorb » March 22nd, 2013, 3:07 am

Sir,
How to capture photograph ( Respondent photo while interviewing) in CsPro data entry application.

Manoj

Gregory Martin
Posts: 1049
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: How to capture Photograph in cspro

Postby Gregory Martin » March 23rd, 2013, 4:28 am

CSPro doesn't support this functionality natively. If you have another program that can take a photo, you can launch that program with the execsystem function.

rcovane
Posts: 26
Joined: August 18th, 2015, 6:45 am

Re: How to capture Photograph in cspro

Postby rcovane » August 18th, 2015, 6:55 am

Ok. I did call the camera and used the command line CSPro suggests. But now, how to customize the image name? For example, i'm mapping a crop and want to take pictures, the file name should be like this:

ID_C##

Where: ID is the Household ID; C means crop; and ## is the crop number.

So i can easily identify the images when i analyse it.

help me modify this code:

execsystem("camera:/storage/emulated/0/csentry/CAPI teste/Imagens/photo.jpg");

htuser
Posts: 318
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: How to capture Photograph in cspro

Postby htuser » August 18th, 2015, 9:30 am

Hi,
Do you already read this post?
viewtopic.php?f=1&t=1026
Regards,

josh
Posts: 1650
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Postby josh » August 18th, 2015, 1:35 pm

For capturing photos I create an item in the dictionary named PHOTO with the following value sets:

PHOTO_TAKEN
Retake photo 1
View photo 2
Keep photo 3
Refused 9

PHOTO_NOT_TAKEN
Take photo 1
Refused 9

Then I use the following logic for the item. This way if you repass through the field after taking the photo it doesn't launch the camera a second time. It also gives you an easy way to see the photo if you are reviewing the questionnaire afterwards.


PROC PHOTO

onfocus
string photoFilename = maketext("%sphotos/photo-%d-%02d-%03d.jpg",
                                
pathname(Application),
                                DISTRICT, VILLAGE, HOUSEHOLD_NUMBER);
if fileexist(photoFilename) then
    
setvalueset(PHOTO, PHOTO_TAKEN);
else
    
setvalueset(PHOTO, PHOTO_NOT_TAKEN);
endif;

postproc
if PHOTO = 1 then
    
// Take/retake photo
    execsystem(maketext("camera:%s", photoFilename));
    
reenter;
elseif PHOTO = 2 then
    
// View photo
    execsystem(maketext("view:%s", photoFilename));
    
reenter;
elseif PHOTO = 3 then
    
// Keep - move to next field
elseif PHOTO = 9 then
    
// No photo - refused
    if fileexist(photoFilename) then
        
filedelete(photoFilename);
    
endif;
    
// Move to next field
endif;

rcovane
Posts: 26
Joined: August 18th, 2015, 6:45 am

Re: How to capture Photograph in cspro

Postby rcovane » August 21st, 2015, 1:40 am

Thank you so much... It helped a lot

alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Postby alesson_aguiar » August 24th, 2015, 1:43 pm

Please, would you mind telling me how I can set these values? I really appreciate any explanation and it would be better if you copy a print of the setvalue page with these informations. Thank you.

josh wrote:For capturing photos I create an item in the dictionary named PHOTO with the following value sets:

PHOTO_TAKEN
Retake photo 1
View photo 2
Keep photo 3
Refused 9

PHOTO_NOT_TAKEN
Take photo 1
Refused 9

Then I use the following logic for the item. This way if you repass through the field after taking the photo it doesn't launch the camera a second time. It also gives you an easy way to see the photo if you are reviewing the questionnaire afterwards.


PROC PHOTO

onfocus
string photoFilename = maketext("%sphotos/photo-%d-%02d-%03d.jpg",
                                
pathname(Application),
                                DISTRICT, VILLAGE, HOUSEHOLD_NUMBER);
if fileexist(photoFilename) then
    
setvalueset(PHOTO, PHOTO_TAKEN);
else
    
setvalueset(PHOTO, PHOTO_NOT_TAKEN);
endif;

postproc
if PHOTO = 1 then
    
// Take/retake photo
    execsystem(maketext("camera:%s", photoFilename));
    
reenter;
elseif PHOTO = 2 then
    
// View photo
    execsystem(maketext("view:%s", photoFilename));
    
reenter;
elseif PHOTO = 3 then
    
// Keep - move to next field
elseif PHOTO = 9 then
    
// No photo - refused
    if fileexist(photoFilename) then
        
filedelete(photoFilename);
    
endif;
    
// Move to next field
endif;

josh
Posts: 1650
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Postby josh » August 24th, 2015, 2:04 pm

alesson_aguiar wrote:Please, would you mind telling me how I can set these values? I really appreciate any explanation and it would be better if you copy a print of the setvalue page with these informations. Thank you.


You add them the same way you would any value set to the dictionary. Click on the variable named "photo" and then click on "add value set" on the toolbar. Do this once for each of the two value sets.

Capture.PNG
Capture.PNG (7.37 KiB) Viewed 4950 times

alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Postby alesson_aguiar » August 25th, 2015, 7:38 am

Josh, thank you for your answer. This is just what I did. but let me tell you what is happening. First, after I enter 1, I take the photo but it is not stored in any folder and I don´t know why. Second, if I enter 2 or 3, I receive "WARNING: Out of range! Please enter a valid value for PHOTO" Can you see and explain it for me, Please?

alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Postby alesson_aguiar » August 25th, 2015, 7:40 am

josh wrote:
alesson_aguiar wrote:Please, would you mind telling me how I can set these values? I really appreciate any explanation and it would be better if you copy a print of the setvalue page with these informations. Thank you.


You add them the same way you would any value set to the dictionary. Click on the variable named "photo" and then click on "add value set" on the toolbar. Do this once for each of the two value sets.

Capture.PNG


Josh, thank you for your answer. This is just what I did. but let me tell you what is happening. First, after I enter 1, I take the photo but it is not stored in any folder and I don´t know why. Second, if I enter 2 or 3, I receive "WARNING: Out of range! Please enter a valid value for PHOTO" Can you see and explain it for me, Please?


Return to “Entry”