How to capture Photograph in cspro

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
manojorb

How to capture Photograph in cspro

Post by manojorb »

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

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

Re: How to capture Photograph in cspro

Post by Gregory Martin »

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

Post by rcovane »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: How to capture Photograph in cspro

Post by htuser »

Hi,
Do you already read this post?
http://csprousers.org/forum/viewtopic.php?f=1&t=1026
Regards,
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Post by josh »

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

Post by rcovane »

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

Post by alesson_aguiar »

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: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Post by josh »

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 15064 times
alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Post by alesson_aguiar »

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

Post by alesson_aguiar »

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?
Post Reply