Help with focus / script issue

achalmersman

Pulling my weight
Joined
Jan 26, 2017
Messages
267
Reaction score
116
Location
Delaware USA
Ok.... so the Dahua sunrise / sunset utility written by bp2008 is a great utility and does 80% of what I need. The problem with it is that it does not do a focus "watchdog" and re-apply the focus commands as needed. I modified this script written by the person in the quote below to keep one of my LPRs in focus at night. The problem is that I don't know how to modify the script to work with the bp2008 utility. You see, if I could have the scrip below check the current schedule setting and apply X focus IF schedule = DAY and Y focus IF schedule = Night I would be golden. Unfortunately I don't know how to do that. Right now my LPR stays blurry during the day because I prioritize night video. This is at my church. Unfortunately just running the bp2008 utility by itself does no good with the Z12 starlight because the camera looses focus on its own day and night. It really is irritating that Dahua can't acknowledge and fix this problem but that's another subject. And it's not because "its not designed for LPR duty" because it does it in the daytime. So if I bought this camera to watch grass grow at 100' away I wouldn't be able to do it. Totally unacceptable in 2018. Thanks for any and all help! Andrew

Figured I would post this in case it is helpful for anyone determining how often they need to refocus.(It turns out that my camera really does not loose focus very often.) You have to have AutoHotKey installed. Place the code in a text file with an .ahk extension. The code will check the current focus, compare it to your desired focus, and write to a log file whether the program needed to change the focus on the camera or if you were already in focus. I plan to run this every hour for a week and then I'll know when I typically loose focus and just run it during those times. You will need to modify the code to include your specific focus and zoom levels, mine are 0.778333 and 0.865225 respectively. You'll also need to enter your own IP and USERNAME and PASSWORD. (I'm not a programmer and so it's probably not the most elegant way to do it, but it works :) The Log file it creates will look like:
Nov-15 11:00PM Focus Unchnaged
Nov-15 11:00PM Focus Unchnaged
Nov-15 11:00PM Focus Reset
Nov-15 11:01PM Focus Unchnaged
Nov-16 05:41AM Focus Unchanged

The AutoHotKey Code:

poststrings =
(Ltrim
http://USERNAME:YOURPASSWORD@YOURIP/cgi-bin/devVideoInput.cgi?action=getFocusStatus
)
loop, parse, poststrings, `n,`r
{
poststring := A_LoopField
URLDownloadToFile,%poststring%, LPR_Focus_Status.txt

}

Sleep, 2000

FormatTime, time, A_now, MMM-d hh:mmtt

FileReadLine, FocusRawData, LPR_Focus_Status.txt, 1
StringTrimLeft, CurrentFocus, FocusRawData, 13

ifEqual, CurrentFocus, 0.778333
{
FileAppend, %Time% Focus Unchanged `n, LPR_Focus_Log.txt
Exitapp
}
else {
poststrings =
(Ltrim
http://USERNAME:YOURPASSWORD@YOURIP/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.778333&zoom=0.865225
)
loop, parse, poststrings, `n,`r
{
poststring := A_LoopField
URLDownloadToFile,%poststring%, LPR_Test_and_Set_Response.txt
FileAppend, %Time% Focus Reset `n, LPR_Focus_Log.txt

}
}
 

Rockford622

Getting the hang of it
Joined
Feb 19, 2016
Messages
188
Reaction score
33
I don't have a ton to contribute to help you out on this issue, but thought I would share my experience.

I just bought 2 Z12 cameras for license plate duty and work really well most of the time. I do use the @bp2008 utility to change from day to night and night to day and that works well. I keep the zoom level the same at day and night, but do change the focus because for some reason the focus in day needs to be different from the focus level at night. The only time my cameras seem to lose focus is when the utility changes from night to day (at the predetermined sunrise time), but the IR lights are still on because it is still somewhat dark. When the IR lights turn off (generally 1/2 an hour after sunrise), the cameras do auto focus and all is good from there.

If you are a Blue Iris user, I was able to attach URL strings to the zoom in and zoom out buttons that appear on the mobile app and UI3 web interface that allow me to set either the day focus value or night focus value as needed remotely.

So, yes, in the meantime, it would be nice to have the ability to periodically check the focus values and compare them to know good values and change if necessary.
 

achalmersman

Pulling my weight
Joined
Jan 26, 2017
Messages
267
Reaction score
116
Location
Delaware USA
Bump. Does anybody out there have a way of maintaining 2 different focal lengths day vs night? Is there a way I can schedule an event using Windows task schedule to run tasks in relationship with sunrise / sunset?

Sent from my SM-G965U using Tapatalk
 

achalmersman

Pulling my weight
Joined
Jan 26, 2017
Messages
267
Reaction score
116
Location
Delaware USA
Did you ever get this working?
Only by concocting two different scripts to run at two different times of the day via Windows task scheduler. It's a complete hack and it's not variable based on sunrise and sunset because I'm not that smart. I meant to get a copy of the script last time I was at the church to post on here and forgot. I will try Sunday

Sent from my SM-G965U using Tapatalk
 

DLONG2

Known around here
Joined
May 17, 2017
Messages
763
Reaction score
454
bp2008's sunrise/sunset utility contains separate settings for day focus and night focus; these aren't working?
 

achalmersman

Pulling my weight
Joined
Jan 26, 2017
Messages
267
Reaction score
116
Location
Delaware USA
bp2008's sunrise/sunset utility contains separate settings for day focus and night focus; these aren't working?
No because that utility does not monitor the focus and readjust as necessary. My cams will loose focus throughout the night (and sometimes day) without a watchdog

The focus system on these cameras is conplete garbage when zoomed in. I get that they are not "designed for" LPR duty, but if I want to zoom in and record stones and grass all day the camera should not lose focus (even in daylight). I have 4 of these and the issue is really only most problematic on the one using the longest focal length. It's like 90% zoomed out

Sent from my SM-G965U using Tapatalk
 

bigredfish

Known around here
Joined
Sep 5, 2016
Messages
17,012
Reaction score
47,460
Location
Floriduh
Yep, I have two of them (Z12's) and have found anything over about 80% zoom is a crapshoot as to whether it will hold focus or not.

I have found two methods that are working well for some time now:
1- Keep the camera in B&W 24/7.
2- Using schedule, change from color to B&W 30-45min before sunset and wait until 30-45min After sunrise to switch back to color.
 

NetHunter

n3wb
Joined
Feb 26, 2018
Messages
28
Reaction score
7
Only by concocting two different scripts to run at two different times of the day via Windows task scheduler. It's a complete hack and it's not variable based on sunrise and sunset because I'm not that smart. I meant to get a copy of the script last time I was at the church to post on here and forgot. I will try Sunday

Sent from my SM-G965U using Tapatalk
thank you would be great.
 

achalmersman

Pulling my weight
Joined
Jan 26, 2017
Messages
267
Reaction score
116
Location
Delaware USA
Ok here goes. I did not write this script. I borrowed it for somewhere and I believe it was this forum. I modified the parameters to do what I needed. I have 2 versions of it. One for daytime, one for nightime. I use Windows Task Scheduler to run the task and repeat it every minute for 9 hrs during the day, and then task scheduler runs the nighttime script every minute for 15 hours. Somebody that is smarter than me could develop one script that could do this, use 2 different focal lengths, check and correct, and vary the time based on sunset / sunrise like the dahua utility also on this forum. The output of this script will create a log file which will show you when it was "unchanged" or reset. Attaching the autohotkey file, as well as just plain text. If you have autohotkey you can modify the script, then compile. I deleted the compiled executable because it would have had my credentials in it. The autohotkey and script info is contained in the zip folder (forum does not except .ahk file attachments).
 

Attachments

Top