Focus strategy in the dark

PeteJ

Getting the hang of it
Jan 14, 2025
167
81
California
I've been struggling with a Uniview PTZ that I am using for LPR. I am trying to use this camera to capture plates at 140-160ft away, and when the camera is in focus, I am able to read the plates clearly. It works w/o any issues during the day time, AF is fast and there isnt much work needed to get it to work.

At night is a whole different game. I need to manually focus the camera, and run 1/250 as the lowest shutter speed. I run gain complete off. The issue is that I am doing this manually--aim at a stationary object to dial in the focus, the ptz to a preset location. The Uniview Light API does not have a usable manual focus. I can turn on manual focus mode, and start a command to focus far or near, but these command are not step wise commands. Once you issue it, it keeps going until you stop, and it's just impossible to focus that way.

How do you set manual focus on your cameras? Any suggestions on an approach that might work on a camera that doesn't have steppings on focus?

Sorry if the question doesn't even make sense. It's been a long day.

Thanks
 
Many have put reflective tape in the field of view - on the curb, catch basin, centerline, etc. to give the camera something to focus on.

But most people that use PTZ for LPR have to basically turn it into a fixed camera for night and have it set on a preset an hour before sunset to give it something to focus on and then not move it - will this camera if tried in that configuration not hold focus?

But this inability to manually set a focus number on a PTZ like we can a fixed camera is why we don't typically recommend a PTZ for LPR.
 
  • Like
Reactions: bigredfish
Really only works if you have enough light to run it in color or just enough to give the camera adequate light to auto focus. Not a good solution otherwise.
 
That is why you pick the cam for the purpose it needs to serve.

You are taking a cam that is not really designed for that job and trying to force it.

Some folks have gotten a PTZ to work for LPR, but many are as frustrated as you.

It is imperative to make sure you get a cam that can be manually focused in the dark and held there. If a PTZ can do this, then fine. If not, get the cam that fits the job.
 
This is what I am working with LOL:
Screenshot from 2025-03-15 09-30-25.png

Those are reflectors in the road that divide the direction of traffic. If the far reflector is bleeding less than the nearest one, it's in focus enough to work, but that's not sufficient for auto focus to work so it has to be done manually. These is a post where I can put on some reflective tape, but it's too close in the foreground so if that was in focus, the plates would not be.

Would focus change if I slow the shutter way down, trigger autofocus, then lock the shutter range back to 1/250 to 1/8000? I've tried switching to night mode before it gets dark, trigger autofocus once to focus, then switch back to manual focus, but once it gets dark, it's out of focus, but I only experimented with this a few times. Would this approach work on security cameras?

One other idea I was toying with is to trigger the camera to focus to extreme far or extreme close. Then trigger the camera to focus in the other direction, and time the stop. In other words, let's say it takes 2.7 seconds to go from extreme far to the point of focus I want, I would issue the focus command and time the stop at 2.7 seconds. Essentially guessing it. Have to factor in network latency and cpu overhead to get it right.

I wasn't prepared to go Mission Impossible level of planning to get focus to work, but here we are. :)

BTW, I am not sure this is a PTZ thing. This other Uniview camera I have also seen to lack this stepped manual focus, but I just set the focus to manual (had my son stand there with a license plate so I could manually focus on it) and left it. It works but day and night.

Thanks for the input guys!
 
That is why you pick the cam for the purpose it needs to serve.

You are taking a cam that is not really designed for that job and trying to force it.

Some folks have gotten a PTZ to work for LPR, but many are as frustrated as you.

It is imperative to make sure you get a cam that can be manually focused in the dark and held there. If a PTZ can do this, then fine. If not, get the cam that fits the job.

I'm the guy with LPR cameras taken off police cars--an actual LPR camera.
 
I'm the guy with LPR cameras taken off police cars--an actual LPR camera.
So the PTZ is a cam taken off of police car?

But it can't be tasked to hold the focus? Then it is not a cam that I would expect it to work for LPR at my home.
 
So the PTZ is a cam taken off of police car?

But it can't be tasked to hold the focus? Then it is not a cam that I would expect it to work for LPR at my home.
Lol. No, not this one. I have about half dozen of LPRs on different properties so I fully understand the importance of using the right tool for the job.

It's fine, I was just checking with the community to see if there are some manual focus strategies that might be useful for cameras that do not have focus stepping.

If these questions aren't welcomed, let me know.
 
  • Like
Reactions: samplenhold
Solved. I'm posting this in case it's useful to someone in the future who has a camera that does not have stepped focusing (the ability to adjust focus by providing the camera a specific value).

The camera I am using is a full size PTZ, branded as a Vigilant VSR-60-02MP3, which is a rebranded Uniview IPC6622SR-X33-VF. This camera supports most of it's functions via an API they call LightAPI, which is accessible via HTTP requests.

curl --digest -u USERNAME:PASSWORD -X PUT -H 'Accept: application/json' -d @$1

the $1 is the JSON file with the PTZ command:

{
"PTZCmd": 516,
"Para1": 0,
"Para2": 0,
"Para3": 0
}

516 is the command to focus far. Once this command is issued, it will continue running until the stop command is issued:

{
"PTZCmd": 515,
"Para1": 0,
"Para2": 0,
"Para3": 0
}


The command to focus near is 514:

{
"PTZCmd": 514,
"Para1": 0,
"Para2": 0,
"Para3": 0
}


and the same stop command:

{
"PTZCmd": 515,
"Para1": 0,
"Para2": 0,
"Para3": 0
}


So to put all this together, you will need to run the focus far command for about 70 seconds. This will max the focus distant out.
Next, you can issue the focus near command in 2 second durations and count how many executions are needed to get to the focus you need.
Once you have that, glue it all together by running a 70 second focus far, then the corresponding number of seconds to focus near to get your desired focus a shell script or whatever your drug of choice is.

It's a little messy, but without an API that allows for stepped focusing, this might be a good enough alternative to make your camera work.

This was good enough to capture plates approx 220-250ft away with IR running at 50% PWM with plenty of room left on the zoom.

Screenshot from 2025-03-16 16-37-18.png
 
  • Like
Reactions: bigredfish