CHDK PTP interface - page 53 - General Discussion and Assistance - CHDK Forum

CHDK PTP interface

  • 1240 Replies
  • 430733 Views
Re: CHDK PTP interface
« Reply #520 on: 17 / June / 2011, 01:58:47 »
Advertisements
ok then ill probably put it on a timer - do you think it will be able to give me around 7-10 fps (rapidly pressing the button gives me a feeling it may be possible)
When I started working on this I tried it out by just dumping the data to files. This got me about 100 images in 5 to 6 seconds, if I recall correctly. The code on the camera is a bit different now, but I don't think it should matter much.

Also, the C# code I wrote to convert the image to an RGB .NET Image might not be the fastest method to get it on the screen. So I would guess 10 fps should definitely be possible (assuming your camera isn't much slower than mine for some reason).


hi mweerden,
just putting a timer and calling the getimagebutton_click() gave me about ( 4 fps ). im just doing a little dirty testing for the moment.

would using overlaybutton_Click() be much different and much faster ? (ill be paching for the pallete for SX 120 next)
i think a little bit of tinkering with the code will juice out around 7-10 fps which should be enough for me for the moment. id like to have more of course if possible. :)

i will post an update on what happens

Re: CHDK PTP interface
« Reply #521 on: 17 / June / 2011, 07:11:13 »
just putting a timer and calling the getimagebutton_click() gave me about ( 4 fps ). im just doing a little dirty testing for the moment.
That's very low. Perhaps you compiled the program for debugging? If found that setting it to "release" and running it outside of VS made quite a difference.

Quote
would using overlaybutton_Click() be much different and much faster ? (ill be paching for the pallete for SX 120 next)
The overlay is smaller (by a factor 3 in my camera). Processing it should also easier/faster. There might be room for improvement by getting and/or processing the palette less often, but this might have a minimal effect.

Re: CHDK PTP interface
« Reply #522 on: 17 / June / 2011, 09:58:08 »
just putting a timer and calling the getimagebutton_click() gave me about ( 4 fps ). im just doing a little dirty testing for the moment.
That's very low. Perhaps you compiled the program for debugging? If found that setting it to "release" and running it outside of VS made quite a difference.
i have indeed compiled for debugging - will try and compile it for release and see. although the gut feeling says the bottleneck is on the camera side. i am almost cretainly wrong as you have recorderded close to 17fps. whatever may be the case, that will be my next step ...

by that time i am converting it to VB.Net (vs2008) so that i can work on my local computer (and think in my local language -basic ;)) and debug it more efficiently. ive almost finished converting it - i am getting the list of ptp devices but not able to connect - i will upload the vb sln if someone is intrested once it is finished.


Quote
Quote
would using overlaybutton_Click() be much different and much faster ? (ill be paching for the pallete for SX 120 next)
The overlay is smaller (by a factor 3 in my camera). Processing it should also easier/faster. There might be room for improvement by getting and/or processing the palette less often, but this might have a minimal effect.
once i convert it to VB and can start thinking i may be able to optimize it a little and use the overlay image if necessary

keep you posted !

Re: CHDK PTP interface
« Reply #523 on: 17 / June / 2011, 12:22:11 »
i have indeed compiled for debugging - will try and compile it for release and see. although the gut feeling says the bottleneck is on the camera side.
You can try disabling the image processing (and drawing) code. That is, make it just receive the image data from the camera but no do anything with it. This won't necessarily give you the maximum output of the camera, but it might be a lot closer.

Perhaps it could also be you are not using a USB 2.0 port?


Re: CHDK PTP interface
« Reply #524 on: 18 / June / 2011, 02:23:22 »
i have indeed compiled for debugging - will try and compile it for release and see. although the gut feeling says the bottleneck is on the camera side.
You can try disabling the image processing (and drawing) code. That is, make it just receive the image data from the camera but no do anything with it. This won't necessarily give you the maximum output of the camera, but it might be a lot closer.

i will do that once the VB Port is complete, i am in a little fix ive got everything on VB but the code fails at
get_video_details() while doing a connect
Sendrequest() - returns ok
ReceiveData() - returns ok
ReceiveResponse() - fails with a timeout at _device.reader.read()

though the problem may be at sendrequest() as i may have messed something and may be sending the command wrong. ill modify your original code to include sent and received response to the log and see what i am doing wrong.

Quote

Perhaps it could also be you are not using a USB 2.0 port?
i always verify that the USB and the Cable is V 2.0 compliant. this was very much the issue while using the camera (older versions SX 110, SX 100, S5, S3 etc) with the CANON SDK which was very picky about V2.0.
however i feel that the connection with CHDK-PTP is much more stable and forgiving.  ;)

just a thought - can a loop be incorporated in to the CHDK itself which will post the image at regular intervals which the receiving program collects - maybe on another thread ? so instead of requesting one instance of the image the command from the computer turns on the feed which the camera posts and another command which can turn it off - maybe suspending the loop while other commands are received if necessary


Re: CHDK PTP interface
« Reply #525 on: 18 / June / 2011, 06:08:42 »
just a thought - can a loop be incorporated in to the CHDK itself which will post the image at regular intervals which the receiving program collects - maybe on another thread ? so instead of requesting one instance of the image the command from the computer turns on the feed which the camera posts and another command which can turn it off - maybe suspending the loop while other commands are received if necessary
It's possible, I'm pretty sure. Not so sure about why, though. It seems to me that it is much easier and much more flexible to pull from the camera when needed.

Re: CHDK PTP interface
« Reply #526 on: 18 / June / 2011, 10:49:25 »
just a thought - can a loop be incorporated in to the CHDK itself which will post the image at regular intervals which the receiving program collects - maybe on another thread ? so instead of requesting one instance of the image the command from the computer turns on the feed which the camera posts and another command which can turn it off - maybe suspending the loop while other commands are received if necessary
It's possible, I'm pretty sure. Not so sure about why, though. It seems to me that it is much easier and much more flexible to pull from the camera when needed.
i would still like to try it once this porting thing s complete. well the problem was the difference in how bit shifting works in c# and vb i think. 
byte a=10; a<<8; would give 2560 in c# i assume, while vb returns 10

well finally i am able to connect to the camera and run the commands. the picture code particularly the conversion to rgb remains to be checked for the same issue (doesnt work) i think i should be able to finish it in a day or two

Re: CHDK PTP interface
« Reply #527 on: 20 / June / 2011, 02:10:14 »
ok so now i am getting the image too, and i think the port is complete...
seems a (sbyte)x works differently than csbyte(x) in vb. if x is a byte and exceeds 127 vb throws an exception while c# quitely converts it to a signed byte.

so here is the source (before i mess it up ;))
http://www.megaupload.com/?d=XUTRK44S

pls note that i have done nothing other than translate mweerdens' excellent code, so he is to be thanked if anyone uses the code. Also note that any bugs which may have crept in during translation are entirely mine :)



Re: CHDK PTP interface
« Reply #528 on: 22 / June / 2011, 08:52:31 »
@mweerden
is it possible by any chance to get a bigger preview image. i am getting a 360x240. any possibility, it can be around something like 640x480 or so  :)

if not any other way in which i can achieve a 5fps at a higher resolution maybe continous shooting - i would be needing 5fps for a minute totalling to 300images.

Re: CHDK PTP interface
« Reply #529 on: 22 / June / 2011, 09:50:09 »
@mweerden
is it possible by any chance to get a bigger preview image. i am getting a 360x240. any possibility, it can be around something like 640x480 or so  :)
Depends on what your camera provides and how much work you are willing to do.

For my ixus870 the actual size of the live image is 720x240 (so it is stretched) and I know the G12 has one that is 720x480. In my test app I just always scale the image (and overlay) to 360x240.

I'm pretty sure this format is fixed (i.e. per camera). The only way I see to get more is to somehow access the real raw data provided by the sensor. I have no idea about the possibilities of this. I do know that it means transferring more data and thus likely a (much) lower fps. Only solution to that would be compression before transfer, but that would mean figuring out how to use the camera's dedicated hardware for this or somehow letting the camera just take pictures/movies like normal and directly stream it to your PC. As far as I know the knowledge for these kinds of things is currently not available.

 

Related Topics