How to capture Photograph in cspro

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Post by josh »

Did you create the photos folder? The logic:

string photoFilename = maketext("%sphotos/photo-%d-%02d-%03d.jpg",
pathname(Application),
DISTRICT, VILLAGE, HOUSEHOLD_NUMBER);

sets the path the folder that the photo to be saved in to a in the photos subfolder of the application folder. For example if you put your application in csentry/myapp and you have district 1, village 1, household 1 then it will try to save the photo as csentry/myapp/photos/photo-1-01-001.jpg. So if the photos directory doesn't exist then the photo won't get saved.

You get the out of range when you enter 2 or 3 because the photo doesn't exist to it uses the second value set which doesn't include 2 or 3. You should set the capture type for the photo field to radio button so that you can see the value set.
alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Post by alesson_aguiar »

I really appreciated your information. Everything is going well. Thank you one more time.
alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Post by alesson_aguiar »

Just one more thing. How can I remove these blank space in the middle of the photo name? (please, consider blank spaces instead of underscore Ex: photo-034-hd_______-25082015.jpg
I am using this code:

Code: Select all

string photoFilename = maketext("%sphotos/photo-%03d-%s-%d.jpg",pathname(application),N_QUEST,NOME,sysdate("DDMMYYYY"));
I also would like concatenate the hour after the date, is it possible? ex: photo-034-alesson-25082015-1215.jpg

thank you for your attention
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to capture Photograph in cspro

Post by josh »

The blank spaces are probaby coming from the alpha variable N_QUEST. Use the strip() function to remove the trailing spaces i.e. strip(N_QUEST). To add the hour you would use the function systime().
alesson_aguiar
Posts: 12
Joined: July 14th, 2014, 4:00 pm

Re: How to capture Photograph in cspro

Post by alesson_aguiar »

Thank you again, it really worked.
rcovane
Posts: 26
Joined: August 18th, 2015, 6:45 am

Re: How to capture Photograph in cspro

Post by rcovane »

alesson_aguiar wrote:
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?

Did you use the code Josh gave? It works, I used the same one this weekend on some tests and I'm very happy with the results. It saves the photos in a folder I named "Pictures" and sets a specific name for each photo.

Don't make many changes, the only change I recommend would be the variables names if you have diferent one . I also added a variable to store the file name and it worked well.

The only thing that didn't work was "refused" option.
rcovane
Posts: 26
Joined: August 18th, 2015, 6:45 am

Re: How to capture Photograph in cspro

Post by rcovane »

Did you use the code Josh gave? It works, I used the same one this weekend on some tests and I'm very happy with the results. It saves the photos in a folder I named "Pictures" and sets a specific name for each photo.

Don't make many changes, the only change I recommend would be the variables names if you have diferent one . I also added a variable to store the file name and it worked well.

The only thing that didn't work was "refused" option.
KAPALA
Posts: 13
Joined: July 18th, 2017, 1:09 am

Re: How to capture Photograph in cspro

Post by KAPALA »

Thank you for constructive comments the forum have been provided. I just go through the page on the discussion about photo. When i take photo i want to save each photos with name,so what should i write in logic?? Suppose i have the following items
Region is a numeric with length 2, District is a numeric with length 2, Ward is a numeric with Length 3, Name of head of household (Alpha with 10 letters), Photo..

I will appreciate if i get such solution
I want the photo to be saved by name of head of household

Thank you

Albert Kapala
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: How to capture Photograph in cspro

Post by khurshid.arshad »

I have done like this

if visualvalue ($(curocc()))=notappl then
execsystem(maketext("camera:%s%04d%03d%03d%07s.jpg",pathname(inputfile),TPS_FEMALE_DICT.PC_NUM,TPS_FEMALE_DICT.Q8, PID_DR, "F_T22_Pic"));

//TPS_FEMALE_DICT.PC_NUM=Processing Code; TPS_FEMALE_DICT.Q8=Household ID; PID_DR=PID from Desk Registration

endif;

Best
a.
A Kasira
Posts: 1
Joined: March 17th, 2019, 11:43 pm

Re: How to capture Photograph in cspro

Post by A Kasira »

am also developing an application using the examples above. but am getting an error after capturing the photo. it says "Camera error,
There was a problem saving your photo or video". I cant figure out the problem
IMG-20190628-WA0004[1].jpg
IMG-20190628-WA0004[1].jpg (49.06 KiB) Viewed 8824 times
Post Reply