obs1dium/FocusBracket

Really slow focus on FE 2.9/90mm on A7RII and suggestion for some improvements

loomitz opened this issue · 20 comments

first of all thanks for your work, I tested the program with the a7RII and I can say it works well, I've testing with the lens, F2.8 GM 24-70 (this works fast and exceptionally) with 90mm F2.8 macro (focus takes a long time to start) and a canon lens adapted with metabones and I can say it works seamlessly with the new metabones native mode, focus a little slow but it works.

Also prove with my a6000 APSC lenses, the 55-210 and 16-50, they work smoothly.

I think the lens that giveme trouble was sadly the more necessary, it would be the 90mm macro, for some reason, with this lens the number of shots is really limited some times only 8 (which I think is easier to solve) and the speed of focus is very slow.

thanks for your attention, and if i can help im something im happy to try.

with this lens the number of shots is really limited

The number of shots is limited by the focusing range, which is divided into discrete steps. For the lenses I tested, the total range consists of 120 steps.
I don't know if your macro lens simply has a narrower range, but it's a possibility.

Thanks, for the reply, the detail with macro lenses is that the path of the barrel is much longer in a shorter distance, for example the distance between 0.92 feet and 1.5 feet is much longer in a macro but the app detects that it is short and gives only a few shots.

I upload a video of the operation of the app with this lens and the other two I have.

https://youtu.be/NXhTEXnur3k

I hope that helps in something

Interesting. Focusing ranges appear to be the same, but focusing speed could indeed be improved.
In the first test, you selected about 1/6th of the total range, so 20 pictures is exactly what you should expect.

ok , I think I understand about the focusing range, but about the the speed of focus I think it has to do something with barrel turns difference between MF and AF lens , the camera always in MF .

example for better understanding.

https://www.youtube.com/watch?v=tsWwzLGx4Gc

3ricj commented

Wow, wait, so this works on the a7rII but not the a7r? Should I try installing the latest version (eg: the new one might work) or is it more that there is a bug specific to the a7r? I am using the same 90mm lens.

Try this, Put the lens the 90mm, in Auto Focus (the ring up), but the camera focus mode in manual, thats the only way that works on A7RII, its slow but works you will notice that you have to do a lot of turns more for focus.

3ricj commented

I have completed a full removal and reinstall of version 1.2. It still locks up/hangs when I press O at the max position and then the app no longer responds. I have tried your method as described, with the lens on AF and camera setting to be on DMF and MF without any luck.

It still locks up/hangs when I press O at the max position

It's possible that your camera does not support the method I use to adjust focus.

I have this lens too and i can confirm it shoots bracketed photos but focusing is very slow. Lens focus ring on AF, camera settings MF.

The first thing I think could help is just to reverse focusQueue (https://github.com/obs1dium/FocusBracket/blob/master/app/src/main/java/com/obsidium/focusbracket/FocusActivity.java#L234). Here is why:

First you set minimum focus. After that you set maximum focus. Therefore the focus ring is in the maximum focus position. When starting shooting the app first moves focus to the minimum position. On 90mm lens this takes a long time. If we start shooting from the maximum position and move to the minimum after we will save some time at the beginning. Made PR #15

Another option is to first pick maximum focus position and pick minimum focus position after.

You could try and check if the FocusDriveListener gets called at all with that lens.

If FocusDriverListener would not be called it would take no photos at all, am I right?

Err, right. I thought I was checking the focus position in another place as well, but apparently not.

This reminds me of a problem I had when doing a similar thing for Magic Lantern (Canon). Now, I'm very new to Sony, so I can't say for sure that the problem is the same. But the issue I had with focusing on the Canon system was that the discrete steps in the focusing range behaved totally different depending on the lens. E.g. sometimes the discrete steps were linear with focusing distance, sometimes the relationship was logarithmic, and especially with cheaper lenses there was hardly a correlation between the two. There was one lens where focussing increments required +4 to actually move the lens one step. And when that lens was steered with +1 increments it would simply not move at all (and therefore freeze the program). I also found a rather wild variety in the total number of steps that any lens would support.

My theory at the time was that it depended on the motor system of the lens. E.g. a stepper motor can be controlled very discretely. But other motor types might not. If that makes any sense...

In the end I found no other way (at least for the difficult lenses) than to record the stepping range into a hard coded dictionary, mapped against their linear distance. Ugly as hell, I know :-)

That said, I tested this FocusBracket app on my Sony A6000. With the Sony 50mm 1.8 it is very slow (but it works). With the 18-105mm OSS it works much faster.

B.t.w. thanks for the app Obs1dium!

Regards,
Philippe

Thanks for the insight, it could very well be that these kinds of issues also affect Sony cameras and lenses.

I recently upgraded from the A5100 to an A6000, and surprisingly focusing with the kit lens is extremely slow now. Not sure why that is, loomitz mentioned in the first post that this camera/lens combination works smoothly.

The only other two autofocus lenses I own (Sigma 19 and 30) are working fine.

Hello obs1dium,

I finally had some time to play with your focusbracket application. And first of all I take my hat off to you! Getting that far while starting from so little is really impressive! And I can only imagine how often you must have opened that LOG.TXT to figure out what the heck was going on. Because a lot in that CameraEx API is not very intuitive, to say the least. So, thumbs up to you obs1dium!

Regarding this variation in speed across systems/lenses, I made some observations that I think might be interesting;

  1. As you mention in your code, higher drive speeds give errors. So I ran a routine that would increment the drive speed until it failed. And I consistently found the maximum to be 7 for all 3 lenses that I tested. So, the drive speed of 4 that you use in the code may be a bit conservative. BUT! ... I can only speek for 3 lenses on one single system (A6000). So, let's just keep it at 4 to be safe. But if we run a little startup routine to determine the real maximum, we might get some drastic speed improvement IMO.

  2. See figure below. I measured the average movement of the focusing system versus the drive speed used in startOneShotFocusDrive(...). As the figure shows, it is very non-linear. But more importantly, there is a significant variation across lenses. E.g. calling startOneShotFocusDrive( far, 1 ) a hundred times, the Sony 50mm would move only 3 positions while the Sony 18-105mm would move 29 positions. AT LEAST... when it is set to 18mm! Which brings me to the next point...

  3. As also seen in the figure, the speed vs. increment of a zoomlens (like the 18-105mm) depends on the actual focal length of the lens. The data seem to suggest that there is some real-world knowledge implemented. I.e. that focussing a wide FOV requires less precision than focussing a narrow FOV (tele-end). If that makes any sense...

  4. If all that is not confusing enough... I also found variations between drive-speed and step-size while using the same lens on the same system. Making all this even more non-deterministic than it already is. But the variations are not big. My first guess is that there might be an accumulator in the system. So that when the lens is driven forward and back a couple times with different speeds, there may still be a leftover that we don't account for when performing steps.

Now, based on these LIMITED and PRELIMINARY statistics, I took the freedom to test your code with the following speed calculation:

if (absDiff > 10)
speed = 4;
else if (absDiff > 5)
speed = 3;
else if(absDiff > 2)
speed = 2;
else
speed = 1;

And focusbracket now works significantly faster. I tested it with all 3 lenses on my A6000 and found no problems. But a bit more testing on different systems would be welcome. Just to be safe.

If we want to push it even a bit further we might try to set speed = 4 to speed = 5 in the above code. But that is under the assumption that 5 is a valid speed on all systems. I have NOT tested that (yet).

Regards,
Philippe

B.t.w. I can't get shiftFocusPosition to do anything either, except for freezing the system...

Explanation of the test setup: I drove the focusing system roughly 100 times for every speed. Then recorded the actual focus position and divided by 100. For some speeds the number of calls had to be a lot less because only a couple calls would already drive focus to max. The results in this sheet give an idea of the relative movement of the focusing system when driven by a single call.

image

Following up on my previous post;

For those who want to try faster focusing with the unproven speed of 5, here is a setting that works fine on my system and with all of my lenses:

        if (absDiff > 20)
            speed = 5;
        else if (absDiff > 4)
            speed = 4;
        else if(absDiff > 1)
            speed = 2;
        else
            speed = 1;

Please note that:

  1. The focusbracket app was using a maximum speed of 4. As for speed 5, all I can say is that it works on my A6000. But it's not proven that it will work on other systems too. If it is not supported I expect it to crash the application. I don't expect your system to go up in smoke... ;-) If it doesn't work for you, just replace speed = 5 by speed = 4. It will only make a difference when you drive focus over a long distance anyway. No worries.

  2. You would be excused for scratching your head over the last check: absDiff > 1. But it's NOT a typo, and it makes quite a difference! Especially with a lens like the 50mm 1.8. As the data suggests, this lens needs to be driven 30+ times with a speed of 1 before it will move 1 position. With roughly 50ms delay on every call, we get around 1.5 seconds. If we would drive it with speed = 1 when we hit absDiff = 2, then this becomes 3 seconds! And so on...

  3. I don't know how critical the above settings are. But if you have a lens that starts hunting, I would suggest to change absDiff > 1 to absDiff > 2. If it still hunts, I have no clue right now. But it would be good to let me know.

I have experimented a little bit with this setting too:

        if (absDiff > 20)
            speed = 5;
        else if (absDiff > 4)
            speed = 4;
        else if (absDiff > 1)
            speed = 3;
        else
            speed = 1;

But I feel that the gain in speed is marginal. And it makes my zoomlens hunt at the widest setting. It comes out of the hunting eventually. But it makes the whole thing actually become slower rather than faster. So... I would advise not to go there.

Grtz and have a nice weekend!
Philippe

Got it to install on A7R2, but it doesn't work

Does not work with my native lens or my adapted Canon lenses.

@fotovideoguy and how is your problem related to this issue? 🙄

I still have not had any luck with gettingthe app to work.
I have installed and uninstalled every version, trying to get it to work.
currently the latest version 1.5 is installed.
When started, I have the minimum and maximum icons on screen and a solid green line between them.
From watching video provided by other users, the app I have installed does not behave as it shows on the A7R2.

I have the lens in AF mode, and set the camera to MF mode, as well, but still no luck.

Really would like to know why it works on some A7R2 anot not others.

Thanks and looking forward to any input that helps to get this working.

@fotovideoguy this issue is about slow focusing with 90mm macro lens as the title says. Please search for issue related to your topic.