Agisoft Metashape

Agisoft Metashape => General => Topic started by: chadfx on July 06, 2013, 08:03:44 AM

Title: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 06, 2013, 08:03:44 AM

I don't think this specific question has been answered before, apologies if it's been covered already.

If I am using CDHK with a Canon compact camera (A3300 IS) and shoot in DNG raw, it does not automatically correct for the lens distortion...so it appears different from the JPGs coming out of the camera. With most cameras this is the expected behavior, aside from some cameras that bake in the distortion correction into their RAWs as well.

Will Photoscan still calibrate correctly for these DNG versions from this camera? I would assume that I would not want to apply any distortion correction in another program before sending it to Photoscan, right?

I know Photoscan should normally handle this as expected, I just wasn't sure in this case, since this camera normally can't shoot RAW.

I'm attaching jpg/dng versions at 28 and 51mm to show the difference between the two versions. Thanks for any info. I imagine it will probably be fairly obvious when I test it out anyway.

-Chad
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 16, 2013, 07:19:18 PM

In case anyone was wondering, the DNG RAW files from the little Canon A3300 w/CDHK kit worked out just fine. The images are MUCH cleaner than the highest quality JPGs the camera spits out. There's still some noise and other issues that go with small/cheap cameras like this, but it certainly is a way to put together a poor man's Infinite Realities. ;-)

This was a quick test with eight of them synced together with a hand built USB trigger.

http://sketchfab.com/show/cAaq3BTHjX26MCZvJijJwyKsjTS
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chrisd on July 17, 2013, 08:18:51 PM
That is excellent!

I've been wanting to do something like this myself ...

What did you use for a rig to hold the cameras?


Chris
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 21, 2013, 08:21:16 PM
Hi Chris,

I used a bit of a hacked together rig, since I've been also testing a multicam setup for other uses and didn't want to set up something permanent just yet. I'm also still trying to find a layout which will help me get the most out of the 8 cameras. I'm using a couple of light stands with super clamps holding two strong flexible arms horizontally. Then each camera is mounted to that with a smaller clamp with a mini ball head, so it makes it relatively easy to move the cameras around in orient them in whatever direction/layout is needed. With all of it on flexible arms, I can expand or contract the arc of cameras as well if I am close or far away from the subject.

The main problems I am running into are trying to get a good build of the geometry under the jaw and near the ears, which are both not seen by as many cameras. So in this rig I placed one camera much lower, which seems to help a bit. I will likely try to get the outer cameras a farther out to the sides next time. I've also been experimenting with different focal lengths and distances from camera. But it all takes time to test out and I haven't figured out how to squeeze more hours out of my day. ;-)

I hope this helps a bit. I can send links to specific pieces of equipment if you are interested. There are some brands sold here in the US (eg. Cowboy Studio) which are sold on Amazon or other online sites that generally have a lot of equipment which mimic the more expensive brands (Manfrotto, etc). It is a bit of a 'you get what you pay for' thing, where they are not as durable or well made; but for some uses (like these small/lightweight cameras) they can save quite a bit of cost.

Here's a pic of a similar camera setup (the two end cameras are usually oriented vertically like the others, not as shown here)  and also the camera/geom solve in PS (for those of you curious about the build quality).

Cheers, -Chad
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: jerry on July 25, 2013, 10:11:13 PM
cool, any new scans? how have you made the camera sync?s?
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 26, 2013, 05:18:37 PM
nothing new just yet...I still want to try expanding the spread of the cameras a bit to get better coverage near the sides of the face. a more even lighting spread also might help. I'll be sure to post better results if I get them.

the cameras are synced well via a USB trigger I built that has a simple button switch connected to all 8 USB ports of the cameras and controlled via the CDHK firmware kit. there is a bit of a delay/lag while they all acquire focus/metering, but once they are all ready/locked, they seem to fire off at about the same time when I release the button. I haven't really tested it with a moving subject, and I have a feeling the sync is not exact enough to pull off something like that. there are sync delay adjustments in the CDHK remote controls, so maybe they can be dialed in fairly close.
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: EMULAT3D on July 27, 2013, 02:51:44 PM
Hey Chad,

Very cool setup! We are actually using the Canon A1400's in our camera rig, but haven't tried the DNG format due to the lens distortion. Have you found that Photoscan works around it nicely? Or do you tend to just do full zoom to reduce the effect?

Thanks!
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 27, 2013, 06:44:22 PM
Hey Emulat3d, I've been converting the DNGs with ACR in Adobe Bridge and it seems to leave the lens distortion in the resulting converted JPGs (as I mention at the top of the post). I never got an official answer if this was a good or a bad thing. ;-)

But I can tell you that PS doesn't seem to mind these DNG-JPGs at all...as it seems to still align the cameras and build the geom without problems. The images certainly have much more image detail than the JPGs coming straight out of the camera. One thing to note is that the cameras are VERY slow to write out the DNGs (2-3secs)...so be patient when you're shooting. =)

It would be great if you gave it a try to see if it works in your situation as well. Good luck!

-Chad
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: andy_s on July 27, 2013, 07:36:54 PM
Hi Chad - apologies if you have already commented about this somewhere else [since it's the weekend i'm even lazier than usual to check the record] :-[.

I do remember briefly looking at reyalp's 'alternative ptp client' topic on chdk a few months ago but hadn't really figured out how to trigger multi cams [via usb] and also transfer images using [another switch ?] the same usb connections before I was distracted.

http://chdk.setepontos.com/index.php?topic=6231.0 (http://chdk.setepontos.com/index.php?topic=6231.0)

Any experience you might share ?

PS: to clarify, I think I had worked out how to trigger multi-cams but not how to transfer images [if possible] using the same usb network...
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 27, 2013, 11:15:26 PM
Hi Andy,

I haven't really explored the alternative CDHK variants out there, but I see exactly why you'd love to have a trigger & transfer USB option. Sort of a cheap Breeze remote system?

Have you looked into SDM? I've seen some chatter about it in the past, and it seems it might have more sophisticated options than what CDHK provides. I think it might do what you want...but I'm not sure how well they are keeping it updated for newer cameras...the web pages appear circa 1998. ;-)

http://www.achillies.com/SDM/Docs/
http://www.achillies.com/SDM/Docs/eng/sdm/upload.htm

I probably would be inclined to explore this option eventually. Right now I'm manually copying images off the cards the old fashioned way...pull card out of camera, stick in computer, copy, eject....repeat x 8  (ugh!)

Please keep us posted on your progress!  -C
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 28, 2013, 12:30:48 AM
and it looks like there might be some of this functionality directly (or a close spinoff) in the CDHK kit:

http://chdk.wikia.com/wiki/PtpCamGui

seems to be a bit less techy to implement at least.
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: andy_s on July 28, 2013, 04:00:42 PM
Thanks for this Chad.

I just reviewed where I had been trying to go with CHDK - that now a few months ago. It was really to try and develop a very large mixed point&shoot / DSLR system.

While I got some level of understanding I got sidetracked and now [just after having read my post on the chdk forum] can't even remember what some of my own post meant  :(

However, if we keep it simply focused on a total point&shoot / CHDK solution I wonder if [within a powered USB hub network] a first switch [say SWITCH1] could be inserted in the final USB connection to the computer and a second switch [SWITCH2] be inserted in between mains supply and the USB hubs.

CHDK Shutter Operation would then require: 

(i) initial conditions - SWITCH1  and SWITCH2 OPEN
(ii) CLOSE SWITCH2
(iii) Wait a second [or so] for all camera's LED lights to say they're ready to shoot
(iii) OPEN SWITCH2 [i.e capture the images]

What I don't understand is whether large propogation time delays are created throughout a USB hub network via hub transfomers etc

(iv) CLOSE SWITCH1 and SWITCH2...use reyalp's alternative ptp client to transfer the images [but since that's a 40 page 392 post topic i'm sure there's a few things to be aware of  :o ;)]

I got involved at post #12 here but quickly got distracted and left it in mid-air...

http://chdk.setepontos.com/index.php?topic=9420.0 (http://chdk.setepontos.com/index.php?topic=9420.0) 

And as a ref:

http://www.flickr.com/groups/stereo/discuss/72157603947882001/ (http://www.flickr.com/groups/stereo/discuss/72157603947882001/)

"The way it [SDM] works is that the camera loads software from the card that adds some new camera menus and controls. one of which is a "sync mode." When this mode is activated, it enters a loop that constantly checks for a voltage on the USB port. When you press and hold the momentary contact switch, it's wired to just deliver power from the battery to the USB's regular power and ground pins. When the software in each camera detects that voltage, it executes the camera's built-in programs to focus, set preflash, etc., and then it executes another loop that just keeps checking for the power to drop. When it detects the power drop, it triggers the final firing sequence. So, you just press the button, wait a second or so for both camera's LED lights to say they're ready to shoot, and release the button to fire both cameras. The sync is very good because that "tight" loop means both cameras detect the voltage drop at very close to the same time, and the firing process after that is fairly "deterministic" (not subject to a lot of randomness), so it happens in both cameras very nearly simultaneously."
 
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: EMULAT3D on July 28, 2013, 05:26:42 PM
Hey Guys,

What we did was create a trigger that would just simply interrupt the power supply on a standard usb hub. This way any cameras plugged in to the hub would be triggered simultaneously by the push of the switch. By default the hub is off until the button is pressed.

Then to pull the images off (still a pain and not ideal) we would just disable remote trigger on the cameras, then connect the hub to the PC to retrieve images (via Windows Picture Import). This is nice because you can then tag the images to a specific camera number.

Hope this helps!
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: andy_s on July 28, 2013, 06:00:59 PM
Thanks for the info EMULAT3D !
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 28, 2013, 08:05:50 PM
Andy, the description from that flickr group post about SDM sounds exactly the way the CDHK switch works as well. The sync varies a bit while all the cameras acquire focus, etc...and then they wait for the voltage drop from the trigger and they stay fairly close in sync.

Emulat3d's solution to switch the power on a USB hub as the trigger (brilliant!) I 'think' should work fine with the basic CDHK remote software as well. Looks like I might have to give this a try!
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: EMULAT3D on July 28, 2013, 09:56:09 PM
No prob guys! That's what's so great with these forums, everyone helps each other. :)

Also, Chad we use CHDK on our cameras and works perfect with the hubs. Just make sure the remote trigger is set to "Two Push". This allows for the first push to focus and second to fire.
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 28, 2013, 10:49:24 PM

Agreed, these forums are the best!

For my remote settings, I've got mine set to 'One Push' for my trigger type and it seems to work fine.

I did a quick test with the USB hub (already connected to the powered on camera).  I just plugged in the power for the hub and the camera locked focus, then pulled the power and the shutter was triggered. It's similar to how I have my basic remote switch set up. The switch is normally 'open' or not connecting the voltage circuit, then I press down (and hold) to 'close' the circuit and supply power over the USB line, which is the 'one push' to do the half press focus lock. When I release the pressure on the switch, it opens the circuit, breaking the voltage connection and initiating the 'full press' and taking the actual photo.

Here's the definition from the CHDK site:

http://chdk.wikia.com/wiki/USB_Remote

OnePush
Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch initiates a "full-press" state for 100 mSec. There is no mechanism to cancel a "half-press" once this sequence is started. Also note that the "half press" will timeout after 10 seconds even if USB power is still applied.

TwoPush
Used with simple switch inputs. Pressing the switch initiates a "half-press" state. Releasing the switch and then immediately pressing the again switch in less than 1/2 second initiates a "full-press" state. Full press state continues while the switch is held. Failing to immediately press the switch the second time will cancel the sequence.
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 29, 2013, 03:33:51 AM
One other note about this that is VERY important if you want to be able to download the RAW files over the USB connection. (you can save the frustration I ran into over this, where none on the DNG files were showing up over the USB connection, only when using a card reader...argh!)

http://images2.wikia.nocookie.net/chdk/images/8/84/CHDK_UserGuide_April_2009.pdf

CHDK RAW and DNG ?les can be downloaded to a computer with the USB cable under the
correct conditions; Instructions from CHDK forum senior member fe50:-
• disable remote in Remote parameters
• use .CR2 as ?le name extension (set up in the CHDK RAW menu)
• before you connect the camera to the computer's USB port you must power off and power on
the camera (important !)
• connect the camera, do not use the Windows transfer assistant - open the Windows Explorer,
• transfer (copy, e.g. with drag & drop or cut & paste) the images to your hard disc.
Mac users - use Image Capture or Canon Camera Window to open when camera is detected.
You can also transfer RAW images in the DNG format this way, but you must use .CR2 ?lename
extension in CHDK; after transferring the ?les you have to rename them (give them the correct
extension - .DNG **).

** and my footnote that I don't think you have to change the CR2 extension back to DNG once they are copied over to the computer (at least not with Adobe Bridge/ACR on the Mac, as it appears to treat them exactly the same)
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 29, 2013, 04:00:51 AM
(oh, and just a small complaint that it's all still a bit tedious, because you still have to turn the remote USB remote function off for EACH camera to be visible over USB,  and also power cycle EACH camera to make the DNG RAW files visible(and don't forget to turn the remote triggering back on when it's time to shoot again!)...but hey, what are you going to do?) 

=)
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: andy_s on December 16, 2013, 01:43:54 PM
...then connect the hub to the PC to retrieve images (via Windows Picture Import). This is nice because you can then tag the images to a specific camera number.

I hope to develop a file/directory download interface that is very flexible [including tagging image to the specific camera and maybe directory = customer_number].

Might someone further comment:

why is it nice to relate image to camera ? [is it useful in automation with python for example ?]

fmi:
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: borgy168 on June 19, 2015, 07:36:21 PM
Hello Guys,

I am glad to have read all your experiences using Raw DNG to JPG.  And Thank you in advance for answering my questions.

I tried shooting in RAW using a CHDK Canon A2300 and compared the result of DNG converted to 100% JPG and the JPG from my canon camera.  I tried 2 batches for the RAW DNG. 1.) unedited converted to JPG and 2.) edited - shadows/highlight contrast but did not touch the noise/ sharpness.  Basing on the output from PS, it seems that JPG from my canon camera has a superior quality than RAW.

How can I maximize the output of my 3d model using RAW DNG file for PS use? 

Is the RAW file generated from A2300 less superior than other P&S models?

Any feedback is helpful :-)

Cheers,

Borgy
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on June 30, 2015, 03:15:11 AM
Hi Borgy, I can't say exactly why you are seeing these differences in the PS computations. When I did my initial RAW vs JPG comparisons, it was only on individual photos and not through the entire PS pipeline. I haven't done much testing with this setup since them, sorry. I'm not if I ever really compared the results as you have here. It's certainly possible that the camera JPGs are a better fit for PS processing.

When you are converting your images from RAW, there are some additional adjustments might be helpful, such as noise reduction, which is likely happening in the camera's JPGs. I would probably suggest starting from a comparison of the photos themselves and verifying that a converted RAW image actually does look better than the camera's JPG. Hopefully that would improve your PS results. There are also a number of different RAW conversion tools, some better than others. I am usually doing this with Adobe's Camera Raw (or Lightroom)

Cheers,  Chad
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: borgy168 on June 30, 2015, 06:15:50 AM

I did a lot of comparison with my A2200 and it seems that JPG conversion from Canon gave me better points.  I tried some noise reduction tool but I got hole on the nose of my model.  Maybe there is something wrong with the way I process the Raw. 

Anyway,  Thanks Chad! Appreciate the feedback.

Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: bigben on July 02, 2015, 07:19:00 AM

If I am using CDHK with a Canon compact camera (A3300 IS) and shoot in DNG raw, it does not automatically correct for the lens distortion...so it appears different from the JPGs coming out of the camera. ...

On this part of the original question...  I wouldn't do any distortion correction prior to using Photoscan as you can either provide calibrated values to Photoscan or have it calculate distortion parameters for you.   If the image offset calculated by Photoscan is different to that used in the in-camera correction then you will effectively be using distorted images.
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: chadfx on July 03, 2015, 11:31:54 PM
That makes sense, thanks. I know that outside perspective correction is a usually a strict no-no for Photoscan. It sounds like it will figure it all out on its own either way (camera corrected JPGs or uncorrected RAWs). I certainly haven't had poor results from the RAWs, but it would be worth a comparison at some point I suppose (if only time were more plentiful...sigh)
Title: Re: Compact Canon CDHK RAW & Lens Distortion
Post by: bigben on July 04, 2015, 06:29:03 AM
Photoscan will figure "something" out regardless but not neces4444444sarily "it"... eg. you can feed it fisheye images and process them as rectilinear and it will figure something out.  The calculations for lens distortion are all done from the optical centre of the image.  If you in-camera correction does this on the geometric centre of the image file and the optical centre of the image is in a different position to this then the final result will be technically distorted, resulting in a mathematical best fit of all of the criteria put together. As a result, camera positions and rotations will also have small errors, compensating for the incorrect distortion correction and you'll see more noise in the sparse point cloud.

If you want a comparison, try creating unfiltered dense clouds.