Dahua Starlight Varifocal Bullet Z12 5.3-64mm (IPC-HFW5231E-Z12)

Did you make sure to switch Profile Management to Schedule in the Dahua software? This may be why your camera is not changing Profiles on the set times.

I haven't figured out a way to make the camera stop focusing automatically. The problem occurs the most in the evening, but can also happen during the day depending on if there are both near and far objects in the frame.

What I have done is use Domoticz to send commands periodically to manually Focus the camera to my desired settings. I send a Focus command 15 seconds after I send the Day profile command. I also have the Domoticz Timer switch automatically send a manual focus command every few hours after Sunrise.

Likewise, I send a Focus command 15 seconds after having Domoticz send the Night profile API command. At night, I send a Focus command every hour because the camera likes to autofocus on the nearer trees.

In Domoticz, I added Hardware/Devices set as Dummy type. I then use the Switches section to add the HTTP codes. Then I use the Timer function on the Switch to issue Day profile command at Sunrise and Night Profile command at Sunset. I added a separate device for each command and switch.

There are probably easier ways to accomplish what you need, but this seemed to do the trick for me until there's a way to lock Focus in the Dahua firmware. I also found that Focus settings during the Day were not great at Night, so I have a separate HTTP command for Day and Night Focus.

Get Focus Status:
http://username:password@<ip>/cgi-bin/devVideoInput.cgi?action= getFocusStatus

Adjust Focus:
http://username:password@<ip>/cgi-bin/devVideoInput.cgi?action= adjustFocus&focus=<focus>&zoom=<zoom>

Day and Night Profile HTTP API:

Day: Z12 - 0 Switches to Day Profile
http://username:password@<IP>/cgi-bin/configManager.cgi?action=setConfig&VideoInMode%5B0%5D.Config%5B0%5D=0

Night: Z12 - 1 Switches to Night Profile
http://username:password@<IP>/cgi-bin/configManager.cgi?action=setConfig&VideoInMode%5B0%5D.Config%5B0%5D=1

If using above Day/Night commands, set Profile Management in Dahua Firmware to Full Time.

Thanks - I spent a lot working on this but still no luck.
I would definitely not recommend this camera with the auto-focus issue.
I don't understand why we can't just set the focus and it not change on it's own.

My camera is constantly out of focus.
 
I don't have focusing issues. Did you try the latest firmware? Maybe it's a software issue.
 
  • Like
Reactions: Alligator
Thanks - I spent a lot working on this but still no luck.
I would definitely not recommend this camera with the auto-focus issue.
I don't understand why we can't just set the focus and it not change on it's own.

My camera is constantly out of focus.

Man, the police came over today to see if I had footage of a car leaving the community.
My LPR (IPC-HFW5231E-Z12) was so out of focus, it was useless. What a crap camera...
 
Man, the police came over today to see if I had footage of a car leaving the community.
My LPR (IPC-HFW5231E-Z12) was so out of focus, it was useless. What a crap camera...

I have to set the focus manually. With the settings it has for LPR, there's not enough light for it to focus itself at night.
 
What are you using to set the focus manually?
Is this camera loose focus in the daytime or not? This camera is not default as a LPR camera, all tested and researched by other members here and find this cost saving way for LPR. So maybe you have some setting wrong? What is your fw No? Maybe i can send you a new FW for updating?

Maybe you can refer to this posting.
Dahua IP-HFW5231E-Z5 LPR settings
 
What are you using to set the focus manually?
I use a home automation software called OpenHAB. It calculates what time of day the sun rises and sets, and then sets the camera profile. I have different profiles for the time of day to get the best setting for the camera to get the best reading.
 
  • Like
Reactions: EMPIRETECANDY
I have the IPC-HFW5231E-Z12 and found the Dahua IP-HFW5231E-Z5 LPR settings no use to me as it overexposes the night images, too much flare from lights and faded licence plates, tonight I set the shutter speed to 1/2000 and aperture to 34 and IR on manual 100% I'm capturing from 90 feet away these settings will vary for everyone distance being 1 factor to consider, I'm trying for a fast shutter speed and a good IR to light the licence plates up then using the aperture to fine tune other light sources out, tonight a car happened to pull up in my target area which was ideal when tuning my aperture.

The autofocus is an issue I wish there was an option to set a fixed focus maybe someone will do a custom firmware at some point otherwise it would be an ideal camera, I have set the night mode to come on early in the afternoon and switch off late on the morning this seems to help but sometimes find the camera has tried to focus in the dark.

The Image at the bottom with the washed out plate below is on the Z5 settings.
 

Attachments

  • Pounteys-NV11ZWP-1509400443-4.jpg
    Pounteys-NV11ZWP-1509400443-4.jpg
    183.2 KB · Views: 150
  • Pounteys-NV11ZWP-1509400458-59.jpg
    Pounteys-NV11ZWP-1509400458-59.jpg
    178 KB · Views: 142
  • Pounteys-NY55WFC-1509399048-8.jpg
    Pounteys-NY55WFC-1509399048-8.jpg
    163.6 KB · Views: 145
Last edited:
I have the IPC-HFW5231E-Z12 and found the Dahua IP-HFW5231E-Z5 LPR settings no use to me as it overexposes the night images, too much flare from lights and faded licence plates, tonight I set the shutter speed to 1/2000 and aperture to 34 and IR on manual 100% I'm capturing from 90 feet away these settings will vary for everyone distance being 1 factor to consider, I'm trying for a fast shutter speed and a good IR to light the licence plates up then using the aperture to fine tune other light sources out, tonight a car happened to pull up in my target area which was ideal when tuning my aperture.

The autofocus is an issue I wish there was an option to set a fixed focus maybe someone will do a custom firmware at some point otherwise it would be an ideal camera, I have set the night mode to come on early in the afternoon and switch off late on the morning this seems to help but sometimes find the camera has tried to focus in the dark.

The Image at the bottom with the washed out plate below is on the Z5 settings.
You can set the focus manually.

Get current focus state:

http://name:pass@10.0.0.XX/cgi-bin/devVideoInput.cgi?action=getFocusStatus

Code:
status.Focus=0.500000
status.FocusMotorSteps=644
status.Status=Normal
status.Zoom=0.877598
status.ZoomMotorSteps=433

Find out what focus level works for you and you can set the focus:

http://name:pass@10.0.0.XX/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.500000&zoom=0.877598

I have a script that checks the focus every 5 minutes and gets it back in check if needed.
 
You can set the focus manually.

Get current focus state:

http://name:pass@10.0.0.XX/cgi-bin/devVideoInput.cgi?action=getFocusStatus

Code:
status.Focus=0.500000
status.FocusMotorSteps=644
status.Status=Normal
status.Zoom=0.877598
status.ZoomMotorSteps=433

Find out what focus level works for you and you can set the focus:

http://name:pass@10.0.0.XX/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.500000&zoom=0.877598

I have a script that checks the focus every 5 minutes and gets it back in check if needed.

What are you using to run the script?
 
What are you using to run the script?
I use a computer running this script:

Code:
<?php
$login = 'user';
$password = 'pass';
$url = 'http://10.0.0.XX/cgi-bin/configManager.cgi?action=getConfig&name=VideoInMode';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
$line = strtok($result, "\n");
$dingo = rtrim($line);
$checkdigit = substr($dingo, -1);
if($checkdigit == 1) {
        $url1 = 'http://10.0.0.XX/cgi-bin/devVideoInput.cgi?action=getFocusStatus';
        $ch1 = curl_init();
        curl_setopt($ch1, CURLOPT_URL,$url1);
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch1, CURLOPT_USERPWD, "$login:$password");
        $result1 = curl_exec($ch1);
        curl_close($ch1);
        $line1 = strtok($result1, "\n");
        $dingo1 = rtrim($line1);
        $pieces = explode("=",$dingo1);
        //echo "$pieces[1]\n";
        if($pieces[1] != "0.165000") {
                //echo "Adjusting focus!\n";
                exec("curl -s -u user:pass --digest -g \"http://10.0.0.XX/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.165&zoom=1\" > /dev/null");
        } else {
                //echo "Focus ok!\n";
        }
}
?>
 
I use a computer running this script:

Code:
<?php
$login = 'user';
$password = 'pass';
$url = 'http://10.0.0.XX/cgi-bin/configManager.cgi?action=getConfig&name=VideoInMode';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
$line = strtok($result, "\n");
$dingo = rtrim($line);
$checkdigit = substr($dingo, -1);
if($checkdigit == 1) {
        $url1 = 'http://10.0.0.XX/cgi-bin/devVideoInput.cgi?action=getFocusStatus';
        $ch1 = curl_init();
        curl_setopt($ch1, CURLOPT_URL,$url1);
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch1, CURLOPT_USERPWD, "$login:$password");
        $result1 = curl_exec($ch1);
        curl_close($ch1);
        $line1 = strtok($result1, "\n");
        $dingo1 = rtrim($line1);
        $pieces = explode("=",$dingo1);
        //echo "$pieces[1]\n";
        if($pieces[1] != "0.165000") {
                //echo "Adjusting focus!\n";
                exec("curl -s -u user:pass --digest -g \"http://10.0.0.XX/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.165&zoom=1\" > /dev/null");
        } else {
                //echo "Focus ok!\n";
        }
}
?>

so this could be put into a batch file that starts automatically when the computer starts?
 
File C:\Users\Berndt\Documents\test.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: :)) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess

not really clued up with scripts I had a dabble years ago with simple scripts things have changed a bit
 
Last edited:
The script I posted is run on a computer running Ubuntu Linux. You may be able to do something similar in Powershell.
 
  • Like
Reactions: Bernie199
I was thinking of installing Ubuntu because this laptop is being used solely for the ALPR camera and this Win10 is being pretty fickle
 
  • Like
Reactions: Go3Team
Thanks - I spent a lot working on this but still no luck.
I would definitely not recommend this camera with the auto-focus issue.
I don't understand why we can't just set the focus and it not change on it's own.
My camera is constantly out of focus.

Are you focusing via the camera's web interface and have you disabled PTZ/control for that camera in BI?