canon ixus 140 control rs_shoot mweerden project - Script Writing - CHDK Forum supplierdeeply

canon ixus 140 control rs_shoot mweerden project

  • 5 Replies
  • 5341 Views
canon ixus 140 control rs_shoot mweerden project
« on: 18 / March / 2014, 04:34:43 »
Advertisements
Hi,

I believe that somewhere in this forum answer to my upcoming question exist, but I couldn't find it  :( . My project is based on mweerden c# project and my goal is:
1) get Live view from camera (done)
2) Take picture
3) write picture to variable in my app
4) shutdown camera(done)

I managed to take picture and save it to a specific folder, but I don't want to create any additional files in PC. Also I am wondering is it possible to use built-in face recognition and get coordinates of eye?

Also I tried to configure eclipse to compile CHDKPTP project, but couldn't do it  :( maybe someone could guide me how to make windows environment ready to start working with it?  :)

P.S. As you already noticed I am a newbie with big goals, but I am left in the field alone  :( and seeking for any help.

*

Online reyalp

  • ******
  • 14111
Re: canon ixus 140 control rs_shoot mweerden project
« Reply #1 on: 18 / March / 2014, 16:39:40 »
I believe that somewhere in this forum answer to my upcoming question exist, but I couldn't find it  :( . My project is based on mweerden c# project and my goal is:
1) get Live view from camera (done)
2) Take picture
3) write picture to variable in my app
If you are just shooting on the camera and downloading (rather than using remote shoot to transfer directly over USB), you just need to make a variant of the download function that keeps the data in memory. I'm not familiar with mweeren's C# code but it doesn't seem like it should be really hard.

Quote
I managed to take picture and save it to a specific folder, but I don't want to create any additional files in PC. Also I am wondering is it possible to use built-in face recognition and get coordinates of eye?
I did some digging into the face related code in http://chdk.setepontos.com/index.php?topic=8243.msg86889#msg86889
This doesn't directly solve your problem, but might point you to the right area to find it.

Quote
Also I tried to configure eclipse to compile CHDKPTP project, but couldn't do it  :( maybe someone could guide me how to make windows environment ready to start working with it?  :)
I build using mingw msys and the included GCC, as documented in the readme. I suggest you do the same. With that, it should just be a matter of adjusting config.mk to point to the dependencies and typing make. On windows, you should also probably download and build Lua with the same compiler, because chdkptp relies on FILE * from Lua being valid with it's own runtime, and this is likely not true for some pre-compiled lua you might download. Pre-compiled IUP and CD should be fine.
Don't forget what the H stands for.

Re: canon ixus 140 control rs_shoot mweerden project
« Reply #2 on: 19 / March / 2014, 03:47:04 »

If you are just shooting on the camera and downloading (rather than using remote shoot to transfer directly over USB), you just need to make a variant of the download function that keeps the data in memory. I'm not familiar with mweeren's C# code but it doesn't seem like it should be really hard.

At this point I am doing this using CHDKPTP CLI which is invoked by my app code bellow
    Process myProcess = new Process();
            folderDelete(); 
            myProcess.StartInfo.FileName = @"C:\BDNS_OFF\chdkptp.exe";
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.Arguments = " -i -c ";
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            string redirectedOutput = string.Empty;
            myProcess.StandardInput.WriteLine("rec");
            System.Threading.Thread.Sleep(200);
            myProcess.StandardInput.WriteLine(@"rs c:\temp\ -jpg");
            System.Threading.Thread.Sleep(5000);
            byte[] photo = basePhoto();
            myProcess.StandardInput.WriteLine("lua shut_down()");
            System.Threading.Thread.Sleep(100);
            myProcess.StandardInput.WriteLine("quit");
            myProcess.WaitForExit();
            folderDelete(); 
            return photo;

this code takes picture, saves it and method basePhoto() from created files and filestream saves it to byte[] array. This code was for testing purpose. Also I don't know from where to begin. I am using this code to communicate with device https://github.com/mweerden/CHDKPTPRemote.

Quote
Quote
I managed to take picture and save it to a specific folder, but I don't want to create any additional files in PC. Also I am wondering is it possible to use built-in face recognition and get coordinates of eye?
I did some digging into the face related code in http://chdk.setepontos.com/index.php?topic=8243.msg86889#msg86889
This doesn't directly solve your problem, but might point you to the right area to find it.

Thanks for the directions I will try to digg into it.

Re: canon ixus 140 control rs_shoot mweerden project
« Reply #3 on: 19 / March / 2014, 04:36:40 »
ok i think I found something from where I could start. 
int ptp_chdk_rcgetchunk(PTPParams* params, int fmt, ptp_chdk_rc_chunk *chunk)
{
   uint16_t ret;
   PTPContainer ptp;

   PTP_CNT_INIT(ptp);
   ptp.Code=PTP_OC_CHDK;
   ptp.Nparam=2;
   ptp.Param1=PTP_CHDK_RemoteCaptureGetData;
   ptp.Param2=fmt; //get chunk

   chunk->data = NULL;
   chunk->size = 0;
   chunk->offset = 0;
   chunk->last = 0;

   // TODO should allow ptp_getdata_transaction to send chunks directly to file, or to mem
   ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &chunk->data);
   if ( ret != 0x2001 )
   {
     ptp_error(params,"RemoteCaptureGetData: unexpected return code 0x%x",ret);
     return 0;
   }
   chunk->size = ptp.Param1;
   chunk->last = (ptp.Param2 == 0);
     chunk->offset = ptp.Param3; //-1 for none
   return 1;
}

as I understand calling PTP_CHDK_RemoteCaptureGetData will solve my problems but I don't understand which params I have to specify.


*

Online reyalp

  • ******
  • 14111
Re: canon ixus 140 control rs_shoot mweerden project
« Reply #4 on: 19 / March / 2014, 17:07:16 »
as I understand calling PTP_CHDK_RemoteCaptureGetData will solve my problems but I don't understand which params I have to specify.
The remote capture sequence is fairly complex, largely due to how it's hacked into the camera code. You can look at the remoteshoot command in chdkptp to see the overall logic there, but it's also quite complex. The command is defined cli.lua http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua?rev=496#L1679

The remote capture logic is in chdku.lua starting around http://trac.assembla.com/chdkptp/browser/trunk/lua/chdku.lua?rev=496#L1128

The camera side code is in rlibs.lua http://trac.assembla.com/chdkptp/browser/trunk/lua/rlibs.lua?rev=496#L1065

The core C code is in ptp.c ptp_chdk_rcisready and ptp_chdk_rcgetchunk

The basic process has several steps
1) run a script on the camera to set up the remote capture http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua?rev=496#L1792 + http://trac.assembla.com/chdkptp/browser/trunk/lua/rlibs.lua?rev=496#L1033
2) run a script to take the actual shot http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua?rev=496#L1802  + http://trac.assembla.com/chdkptp/browser/trunk/lua/rlibs.lua?rev=496#L1065 (this could be combined with the above script, if you don't care about checking status, but it's important that the second call doesn't wait for the script to finish executing, because it won't finish until you finish the download)
3) set up handlers to deal with the data http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua?rev=496#L1808 (this is because the chdku.lua code is generic to allow doing different things with the data, your code wouldn't need to work this way)
4) poll the camera wait for the requested filetypes to become available http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua?rev=496#L1843 http://trac.assembla.com/chdkptp/browser/trunk/lua/chdku.lua?rev=496#L1128 - this ultimately calls ptp_chdk_rcisready
5) when a file becomes available, call ptp_chdk_rcgetchunk to get all the chunks of the file. This is done in the handlers set up earlier. Note that for camera jpeg, the handler may need to seek building the file.

In earlier development, srsa wrote an all C implementation of this, but note that it doesn't have the seeking code and has some other differences from the final protocol. See http://trac.assembla.com/chdkptp/browser/trunk/ptp.c?rev=299#L1928

If you write a C# implementation, I'm sure others will find it useful.

The development thread may also prove useful, starting around this post http://chdk.setepontos.com/index.php?topic=4338.msg88931#msg88931
Don't forget what the H stands for.

Re: canon ixus 140 control rs_shoot mweerden project
« Reply #5 on: 20 / March / 2014, 04:54:45 »

Once again thanks for help. At the beginning I thought it would be a easy ride, but...  :o I will get back to it later next week because I have to get ready my current APP to work   :'( or my PM will be  >:(
And of course if I will manage to finish it I will be glad to share it.
« Last Edit: 20 / March / 2014, 04:57:45 by jonasr »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal