Continuous distance measurement

  • 4 Replies
  • 997 Views
Continuous distance measurement
« on: 20 / August / 2014, 04:31:29 »
Advertisements
Helo,

is it possible to measure and display the distance to an object continuously.

About help I would be very happy.

Greetings

Re: Continuous distance measurement
« Reply #1 on: 20 / August / 2014, 05:44:59 »
is it possible to measure and display the distance to an object continuously.

Not with any accuracy, and you have to half-press each time to update the reading.

These small-sensor cameras have very large depth-of-field, especially at the wide-angle setting.
The only thing the Canon firmware knows is aperture (if any),focal length and position of the focus stepping motor.
From that it infers focused distance.
A single focus step may move focus from two metres to four metres.
There is better accuracy at long focal lengths.


David

Re: Continuous distance measurement
« Reply #2 on: 20 / August / 2014, 07:43:31 »
is it possible to measure and display the distance to an object continuously.
The answer to your question is yes.  All you need is a small CHDK script.

However, as microfunguy points out, the accuracy will not be very good.  In addition, for many of the same reasons, the precision will likely be poor.

So the question you need to ask yourself is how much precision & accuracy do you need ?   Also, the camera will tend to focus on whatever objects it can find near the center of the image. Is that acceptable too?

If you still want to try this,  I can post a small script for you.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Continuous distance measurement
« Reply #3 on: 20 / August / 2014, 09:44:54 »
I was curious to see how well this would actually work. The results were better than I expected using my A1200 but still nothing I would consider a precision measurement.

Code: [Select]
--[[
@title Distance Meter
--]]

function update_display(msg)
    draw_string(xpos,ypos,string.sub(msg, (string.len(msg)/2)-6, (string.len(msg)/2)+5), white, blue, text_size)   
end

    transparent = 256
    black = 257
    white = 258
    red = 259
    green = 263
    blue = 266
    yellow = 271
    xpos =  50
    ypos =  50
    text_size = 2
    strmsg = "    start     "
   
    if ( get_mode() == false ) then             -- switch to shooting mode on start up
       sleep(1000)
       set_record(1)
       while ( get_mode() == false) do sleep(100) end
    end
    sleep(500)   
    repeat
        press("shoot_half")
        count = 0
        repeat
            update_display(strmsg)
            sleep(100)
            count = count + 1
            if (count > 40 ) then timeout = true end
        until (get_shooting() == true ) or (timeout == true) 
        release("shoot_half")
        if ( timeout == true ) then
            strmsg = "  timeout  "
        else
            sd = get_focus()
            if ( sd == -1 ) then
                strmsg = "    infinity     "
            else
                strmsg = "     "..get_focus() .." mm     "
            end
        end
        for i=0, 10, 1 do
            update_display(strmsg)
            sleep(100)
        end
    until false   
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Continuous distance measurement
« Reply #4 on: 20 / August / 2014, 10:33:35 »
Hi,

thanks, that really helped.
The inaccuracy is not a big problem.

Thanks again, now I can go on.


nocaC_230

 

Related Topics