Log in or register to post comments

Camera and auto focus

December 6, 2010 - 2:22pm #1

Hello,

Is there a way to launch an auto focus on the camera?

In my app we look the marker from 3-4 meters so and the image is very blurry so the tracking is not so good. How can we get the camera and let the user launch an auto-focus when he is at the desired distance?

Thank you.

Re: Camera and auto focus

May 4, 2011 - 4:43pm #18

It's actually pretty easy. I looked at the FrameMarkers sample to see what happens, and there's now an autofocus() native method which you can invoke to get AF.

Now what would be interesting is if it's possible to have continuous auto-focus! :)

Re: Camera and auto focus

May 4, 2011 - 2:51pm #17

I noticed the auto-focus update in the post-beta documentation.
Sweet!!
Haven't had a look at code yet, but I'm pretty sure, I was on the right track:D

Re: Camera and auto focus

May 1, 2011 - 3:21pm #16

Yeah actually I do have some advice, now.

Upgrade to SDK v1 - the native camera object now supports auto-focus :)

Re: Camera and auto focus

April 23, 2011 - 12:48pm #15

Well I added the following in "AndroidManifest.xml" :Commented too:)

Add this permission to get access to the autofocus function

Refreshed Project, and run, but auto-focus box not appearing in scene, so I thought it might have to be called from within camera activity:

/** Tells native code we are using autofocus */
public native void onAutoFocus (boolean success, Camera camera);

Still not working, so not as simple as thought...I do think i'm on the right track though, any advice xercesb??

Re: Camera and auto focus

April 23, 2011 - 5:09am #14

How'd you go, zimmer?

Re: Camera and auto focus

April 22, 2011 - 3:54pm #13

Hi Guys, I would also like to add autofocus functionality to my project, and came across this feature on Android Dev Site:

http://developer.android.com/reference/android/hardware/Camera.AutoFocusCallback.html

It seems we might be able to simply declare this feature in the AndroidManifest.xml file. Ill give it a go and report back;-))

Re: Camera and auto focus

April 4, 2011 - 5:14am #12

We are looking at the auto-focus feature. The next release should be sometime in Q2 of this year.

- Kim

Re: Camera and auto focus

April 1, 2011 - 9:37pm #11

Hi there - just wondering if there's been any further movement on the whole auto-focus feature? I can't seem to get the camera app trick to work on my N1

Wondering if/when the next point-release of the SDK will be made available and whether auto-focus will be a feature of that release?

Re: Camera and auto focus

December 8, 2010 - 6:49am #10

:)

It seems that I rely to much on Eclipse. The header wasn't referenced in other any file and seeing only the forward declarations in Frame such as for FrameEx and FrameData I thought that it was intentional not to have it public and such I never did continued my search.

Thank you,
Alex.

Re: Camera and auto focus

December 8, 2010 - 6:10am #9

Hmm, you're probably just missing the include for the Image class:

#include

The camera mode is meant to provide you with some measure of control of the camera downsampling, I'm not sure that we'll be adding full resolution control any time soon though. The SDK will evolve with the technology, however!

- Kim

Re: Camera and auto focus

December 8, 2010 - 12:27am #8

Hi,

The camera adjusts the exposure pretty well on its own. The focus handling is the most troublesome.

I was looking over the qcar ndk and I only see the forward declaration of QCAR::Image (same for FrameData and FrameEx).

Just to be sure I also tried to compile the snippet (thank you for that) you posted and the compiler complained about the same thing.

I've also did a listing of camera modes based on quality:
MODE_DEFAULT/MODE_OPTIMIZE_SPEED/MODE_OPTIMIZE_QUALITY

FrmRate: 26.667 480x320
FrmRate: 26.667 320x240
FrmRate: 26.667 640x480

Is this the same info that I could have got via your code snippet ?

Also, It would be nice in the future to have a way of choosing these resolutions ourselves (even full frame/ no down-sampling) -> let's say we write this prog and in the meantime some spectacular cpu appears, we should let the user decide upon perceived/needed performance or accuracy of computations ;D .

All the best,
Alex.

Re: Camera and auto focus

December 7, 2010 - 2:47pm #7

First, I might suggest printing off the target :) The camera might not be reacting well to the backlighting on the monitor. Good lighting is always important in AR, but we're typically talking ambient lighting.

To find the resolution of the camera image, use the following code snippet anywhere you have the State object:

QCAR::State state = QCAR::Renderer::getInstance().begin();

QCAR::Frame frame = state.getFrame();

for (int i = 0; i < frame.getNumImages(); i++)
{
    const QCAR::Image* image = frame.getImage(i);
    int width = image->getWidth();
    int height = image->getHeight();
    
    switch (image->getFormat())
    {
        case QCAR::RGB565:
            LOG("rgb565 %dx%d", width, height);
            break;
        case QCAR::RGB888:
            LOG("rgb888 %dx%d", width, height);
            break;
        case QCAR::GRAYSCALE:
            LOG("grayscale %dx%d", width, height);
            break;
        case QCAR::YUV:
            LOG("yuv %dx%d", width, height);
            break;
    }
}

The rgb565 camera image is rendered to the background, and the grayscale image is used for tracking. I'm getting 400x240 for the grayscale image on my HTC desire.

I'm not sure if you're going to be able to add auto-focus functionality on your own, but I'm asking around. I'll let you know what I find.

- Kim

Re: Camera and auto focus

December 7, 2010 - 2:00pm #6

Hi,

Please see my life's story below
...............
? question?

To what resolution(s) are you downsampling the camera feed?
...............

I'm just lazy to print out the trackables and such I use those 2 from the "Run The Sample App" page (just point the phone to the screen with the web page opened). Such they are not the actual A4 size :D and any errors propagate faster with the distance.

Anyway. The problem was that the image was blurry and even if I was at a somewhat close distance (20/30 cm) the tracking was lacking consistency. Then I realized that the focusing is off (at first i thought that blurring was just some rendering "optimization" from the lib) . So I did the focusing in the Camera App and switched to the ar app. Everything was fine.

I also see that we have access to almost all we need to reimplement the autofocus functionality (not that keen on that, downloaded some pdfs).

>>ADDED 1 yet on googling i see that this is some 3 MP sensor. Will this work with the HTC Desire HD ??? or it's just for fun in the ndk (+ no linux ioctl exp).

>>ADDED 2

I think that at first we should try to use the camera autofocus functionality from java and see how that works out and how well this integrates with the ar lib.

In the mean time the ar app->camera app-> ar app switch is not that bad / frequent.

All the best,
Alex

Re: Camera and auto focus

December 7, 2010 - 1:08pm #5

What device are you using? It's possible that camera focus is better/worse depending on the device. Alex, are you also trying to track from a long distance?

- Kim

Re: Camera and auto focus

December 7, 2010 - 1:01pm #4

Hi,

I think this is actually a big problem. I have to enter first in the camera app, focus on what I want to track and than switch back to the ar app.

I think that it might be possible to get the focusing functionality from some camera lib from android sdk/ndk and somehow either switch between libs(stop camera via ar lib start via the other and back) or, if there aren't any exclusive locks on the camera, use both at the same time.

Can someone see if it's possible ?

All the best,
Alex.

Re: Camera and auto focus

December 6, 2010 - 3:00pm #3

Thanks, it would be great, it's really a big problem for what I want to do.

In the meantime I think I can try to find the best marker possible for a long range detection.

Re: Camera and auto focus

December 6, 2010 - 2:44pm #2

This isn't possible with the current version of the SDK. It is an interesting request however, I'll file a feature request and we'll see where it goes :)

- Kim

Log in or register to post comments