FORUMS
Remove All Ads from XDA

Camera - Manual Focus

235 posts
Thanks Meter: 4
 
By hypest, Retired Recognized Developer on 10th February 2010, 10:34 AM
Post Reply Email Thread
Hello devs!

I wonder if anyone is interested in/capable of implementing a manual focus feature in android, at least for G1. Hardware-wise, I think it is probably feasible since (the great dev) DZO has already done it for the Kaiser (and I have seen it in action)!

CLARIFICATION EDIT: by Manual Focus I mean controlling the focal length, not just triggering the autofocus. For example, on the Kaiser, dzo has mapped the up/down side-wheel to focus-farther/focus-nearer!

See here the source code commit.

It would be great if the implementation introduced a relevant Java-level API, or extent the current Camera API.

My idea is to use this feature to fix-focus the camera, just a few centimeters away and make barcode scanning faster, not relying so much on auto-focusing. But I'm sure that there are plenty more useful stuff that can be done with manual focus (e.g. inspiring/artistic photo captures).

I'm rather new in android-dev and not experienced enough (yet) to work on the below-Java space, that's why I'm kindly asking for someone else to have a look at it

any thoughts?

have fun,
hypest
The Following 2 Users Say Thank You to hypest For This Useful Post: [ View ] Gift hypest Ad-Free
10th February 2010, 12:13 PM |#2  
djluis48's Avatar
Senior Member
Flag Santo Domingo
Thanks Meter: 233
 
More
This is a great idea. Hope to see someone working on it.
10th February 2010, 03:43 PM |#3  
Member
Flag Virginia
Thanks Meter: 1
 
More
This would be awesome! Espcially for photographers like muah
The Following User Says Thank You to lapalways05 For This Useful Post: [ View ] Gift lapalways05 Ad-Free
10th February 2010, 04:54 PM |#4  
MattKilla's Avatar
Senior Member
Flag Seattle, WA
Thanks Meter: 4
 
More
Quote:
Originally Posted by lapalways05

This would be awesome! Espcially for photographers like muah

Photographers use shoddy-quality 3MPx cameras? Is your dSLR in the shop or something?
10th February 2010, 05:08 PM |#5  
Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by MattKilla

Photographers use shoddy-quality 3MPx cameras? Is your dSLR in the shop or something?

No, but it's not in my pocket most or all of the time, either. In a pinch, between 3Mpixel and 0Mpixel, the photographer will usually choose the former.
10th February 2010, 06:40 PM |#6  
Geniusdog254's Avatar
Retired Recognized Developer
Flag St. Louis
Thanks Meter: 169
 
Donate to Me
More
Quote:
Originally Posted by marxmarv

No, but it's not in my pocket most or all of the time, either. In a pinch, between 3Mpixel and 0Mpixel, the photographer will usually choose the former.

Yeah exactly. I love my dSLR to death, but I can't always have that beast with me. My phone is ALWAYS with me. I would a lot rather take a quick shot with it than no shot at all.

To the OP. Look in the android source repo at the camera code. Or is the G1 camera drivers in the closed source area? I know the actual camera driver is (thats why 2.X didnt have a camera at first) but is the AF code there too?
10th February 2010, 06:54 PM |#7  
Meltus's Avatar
Senior Member
Flag Manchester
Thanks Meter: 1,045
 
Donate to Me
More
As the phone has auto focus i see no reason why manual focus couldn't be coded in.
In fact, i'm surprised no one has done it yet. I remember it being done on my old LG Viewty (that had a fantastic camera) and my SE k750i and was great for the really close up shots that the auto focus can't normally achieve.
10th February 2010, 07:27 PM |#8  
Geniusdog254's Avatar
Retired Recognized Developer
Flag St. Louis
Thanks Meter: 169
 
Donate to Me
More
Ok I looked at the code. Here is the camera code for the MSM7xxx chips:

http://android.git.kernel.org/?p=pla...re.cpp;hb=HEAD

http://android.git.kernel.org/?p=pla...ware.h;hb=HEAD

http://android.git.kernel.org/?p=pla..._ifc.h;hb=HEAD

If you look at the first one, it does all its autofocus calls thru libqcamera. That is one of the proprietary HTC/Qualcomm drivers. Here is the code:

Code:
status_t QualcommCameraHardware::autoFocus(autofocus_callback af_cb,
                                               void *user)
    {
        LOGV("Starting auto focus.");
        Mutex::Autolock l(&mLock);
        Mutex::Autolock lock(&mStateLock);

        if (mCameraState != QCS_PREVIEW_IN_PROGRESS) {
            LOGE("Invalid camera state %s: expecting QCS_PREVIEW_IN_PROGRESS,"
                 " cannot start autofocus!",
                 getCameraStateStr(mCameraState));
            return INVALID_OPERATION;
        }

        if (mAutoFocusCallback != NULL) {
            LOGV("Auto focus is already in progress");
            return mAutoFocusCallback == af_cb ? NO_ERROR : INVALID_OPERATION;
        }

        mAutoFocusCallback = af_cb;
        mAutoFocusCallbackCookie = user;
        LINK_camera_start_focus(CAMERA_AUTO_FOCUS, camera_cb, this);
        return NO_ERROR;
    }
First off you can see its calling the QualcommCameraHardware library which is libqcamera and then the method autoFocus. I think this is a dead end.

However, for 2.X we reverse engineered the drivers since we didn't have them available. They are open source. We may be able to look at them and get how they use the AF code.
10th February 2010, 08:42 PM |#9  
hypest's Avatar
OP Retired Recognized Developer
Flag Thessaloniki
Thanks Meter: 4
 
More
Geniusdog254, thanx for sharing your thoughts, info and findings.

I'm assuming here: if the AF is done in software, even in proprietry drivers, it may indeed be possible to use it by RE it. Best case scenario would be to find functions lingering in there, waiting to be called

I'm wondering though, if the IOCTL's dzo is using are directly triggering hardware "switches", or are they handled in the drivers...

Could you please also share links to the open sourced 2.x driver?
10th February 2010, 09:00 PM |#10  
Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by Geniusdog254

First off you can see its calling the QualcommCameraHardware library which is libqcamera and then the method autoFocus. I think this is a dead end.

Maybe not. I vaguely remember that the HTC camera app from CM 4.0 or 4.1 would allow you to switch between autofocus and infinity focus. Maybe that's a start?
11th February 2010, 12:39 PM |#11  
hypest's Avatar
OP Retired Recognized Developer
Flag Thessaloniki
Thanks Meter: 4
 
More
I found these symbols in the libqcamera.so on my CM g1 (and highlighted some interesting ones):

Code:
af_algo_config
af_algo_execution
af_algo_preview
af_check_aec_settled_cnt
af_do_move_lens
af_done
af_do_process_exhaustive_search
af_do_process_hill_climbing
af_do_reset_lens
af_do_safe_move
af_init_process_exhaustive_search
af_init_process_hill_climbing
af_is_active
af_move_lens_to
af_process_focus_sensor
af_process_lens_move_done
af_process_start_focus
af_process_stats
af_read_process_type
af_read_sharpness
af_start_stats
af_stop_focus
seems to me that maybe there are suitable means for manipulating the lens/focus.

I've attached the whole readelf dump...
Attached Files
File Type: zip libqcamera_so_readelf_output.zip - [Click for QR Code] (12.8 KB, 223 views)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes