[SOLVED] Axis M3025-VE - constantly switching between day/night modes

A place for discussion of topics that are not specific to ZoneMinder. This could include Linux, Video4Linux, CCTV cameras or any other topic.
Post Reply
Greg_Talyor
Posts: 34
Joined: Mon Aug 17, 2020 7:41 pm

[SOLVED] Axis M3025-VE - constantly switching between day/night modes

Post by Greg_Talyor »

When I have an Axis M3025-VE camera's IR filter on auto, it ticks — switching between day/night modes — like a clock (as in tick-tock, tick-tock) for good several minutes during dusk and dawn. Can't they just have its light sensor less accurate? The problem is more profound when I have WDR switched on. My workaround at the moment is switching IR filter off altogether. But it also means that I have B/W images all the time. I actual quite like colour images during daytime. I have seen some cameras have hysteresis setting (e.g. Vicon <https://vicon-security.zendesk.com/hc/e ... umination->) on day/night mode switching, but I can't find it on my Axis cameras.

I welcome any suggestions to solve this problem.

Ta.
Last edited by Greg_Talyor on Thu Sep 17, 2020 6:37 pm, edited 2 times in total.
Greg_Talyor
Posts: 34
Joined: Mon Aug 17, 2020 7:41 pm

Re: Axis M3025-VE - constantly switching between day/night modes

Post by Greg_Talyor »

Greg_Talyor wrote: Thu Sep 10, 2020 11:48 am When I have an Axis M3025-VE camera's IR filter on auto, it ticks — switching between day/night modes — like a clock (as in tick-tock, tick-tock) for good several minutes during dusk and dawn. Can't they just have its light sensor less accurate?
I have some initial responses from Axis technical support. They say they are looking into the problem. But from the tone of it, it doesn't sound promising. I am imagining the following cron jobs and hoping they might able to exist in one form or the other.

It happens twice (dawn and dusk) a day, every day without fail on each camera. Am I the only person having such a problem?

--- * --- * ---

Every morning at 05:00
rtsp://user:password@camera/onvif-media/media.amp?IrCutFilter=on

And every evening at 19:00
rtsp://user:password@camera/onvif-media/media.amp?IrCutFilter=off

Ta.
Last edited by Greg_Talyor on Thu Sep 17, 2020 4:54 pm, edited 1 time in total.
mikb
Posts: 585
Joined: Mon Mar 25, 2013 12:34 pm

Re: Axis M3025-VE - constantly switching between day/night modes

Post by mikb »

I'm assuming your original problem is when the camera is in "auto" mode, and it decides whether to IR-cut based on illumination level.

Of course, if it is switching on an IR source, this will increase illumination which will cause it to think it's daytime again. It may just be with the IR cut filter removed (for night view) it can suddenly see a brighter picture, so it thinks it's day for that reason instead.

Yes, it needs more hysteresis, it's not rocket science. Automated "dusk lights" have to figure this stuff out so they don't switch themselves off, by switching on ... :) So camera manufacturers really should have fixed this!

As to your cron jobs, that's one way to resolve it, although you might want to look at the ingenious "sunwait" which will give you a more accurate switching time based on your location and timezone!

https://risacher.org/sunwait/
Greg_Talyor
Posts: 34
Joined: Mon Aug 17, 2020 7:41 pm

[SOLVED] Re: Axis M3025-VE - constantly switching between day/night modes

Post by Greg_Talyor »

Problem SOLVED!
mikb wrote: Thu Sep 17, 2020 3:58 pm Yes, it needs more hysteresis, it's not rocket science. Automated "dusk lights" have to figure this stuff out so they don't switch themselves off, by switching on ... :) So camera manufacturers really should have fixed this!
Absolutely, what I needed is hysteresis, but now I'll settle for a cron job.

It turns out that the chap from Axis technical support is not entirely capable, but he gives me sufficient clues to allow me fooling around here and there. He didn't even give me any documentation, but Google Search saves the day! I'm asking him to give me an up-to-date version of that document.
By luck, I bump into this:
<http://www.consultorimaterdomini.it/ind ... =9%3Aprova>
Axis Communications AB (2008) VAPIX® version 3: HTTP API
These work for me.

Code: Select all

http://user:password@camera/axis-cgi/param.cgi?action=list&group=root.ImageSource.I0.DayNight.IrCutFilter
http://user:password@camera/axis-cgi/param.cgi?action=update&root.ImageSource.I0.DayNight.IrCutFilter=auto
http://user:password@camera/axis-cgi/param.cgi?action=update&root.ImageSource.I0.DayNight.IrCutFilter=yes
http://user:password@camera/axis-cgi/param.cgi?action=update&root.ImageSource.I0.DayNight.IrCutFilter=no
The most frustrating thing is that the valid values for IrCutFilter parameter are actually auto/yes/no instead of Auto/On/Off as in the web interface.
Thinking aloud works.
mikb wrote: Thu Sep 17, 2020 3:58 pm As to your cron jobs, that's one way to resolve it, although you might want to look at the ingenious "sunwait" which will give you a more accurate switching time based on your location and timezone!

https://risacher.org/sunwait/
Surely, sunwait is the next thing I'll do. But when a star destroyer arrives me during daytime or a supernova explodes during night time, I won't have the correct camera setting to capture the events.

Ta.

--- * --- * ---

Update on 18 Sep. Just in case someone else might have the same problem that I had, here is my cron job.

Code: Select all

00 19 * * * (echo -n `date`; echo -n "\tTurn IR Filter OFF  \t"; curl --request GET 'http://user:password@camera/axis-cgi/param.cgi?action=update&root.ImageSource.I0.DayNight.IrCutFilter=no' ; echo) >> ~/foo/bar/cron_ircutfilter.log
01 19 * * * (echo -n `date`; echo -n "\tAsk IR Filter status\t"; curl --request GET 'http://user:password@camera/axis-cgi/param.cgi?action=list&group=root.ImageSource.I0.DayNight.IrCutFilter'      ) >> ~/foo/bar/cron_ircutfilter.log
00 05 * * * (echo -n `date`; echo -n "\tTurn IR Filter ON   \t"; curl --request GET 'http://user:password@camera/axis-cgi/param.cgi?action=update&root.ImageSource.I0.DayNight.IrCutFilter=yes'; echo) >> ~/foo/bar/cron_ircutfilter.log
01 05 * * * (echo -n `date`; echo -n "\tAsk IR Filter status\t"; curl --request GET 'http://user:password@camera/axis-cgi/param.cgi?action=list&group=root.ImageSource.I0.DayNight.IrCutFilter'      ) >> ~/foo/bar/cron_ircutfilter.log
In order to use sunwait, I need to have a cron job to change another cron job. Um ... that's perverse.

--- * --- * ---

Update on 25 Sept. I change my mind. I can actually have a daily cron job to run two at jobs at a time. That's less messy. It is useful to think aloud.
Greg_Talyor
Posts: 34
Joined: Mon Aug 17, 2020 7:41 pm

Re: [SOLVED] Axis M3025-VE - constantly switching between day/night modes

Post by Greg_Talyor »

Below please find my final solution.

day-night.pl

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;

# called by cron, in crontab:

# mm hh dom month dow command
# 55 02 * * * perl /home/user/foo/bar/day-night.pl
# making sure it is local time after daylight time switching

# usage:
#     ./day-night.pl
#         no arguments required

# required:
#     ./on-off.pl (in the same directory of this script)
#     /usr/local/bin/sunwait

# sunwait options: daylight, civil, nautical, astronomical, angle [X.XX]
# Twilight types, either:
#     daylight      Top of sun just below the horizon. Default.
#     civil         Civil Twilight.         -6 degrees below horizon.
#     nautical      Nautical twilight.     -12 degrees below horizon.
#     astronomical  Astronomical twilight. -18 degrees below horizon.
#     angle [X.XX]  User-specified twilight-angle (degrees). Default: 0.

my $rise_set = `/usr/local/bin/sunwait list offset -0:15:00 38.89769N 77.03653W`;
$rise_set =~ m/(\d\d:\d\d), (\d\d:\d\d)/;
my ($dawn, $dusk) = ($1, $2);
my ($dawn_offset, $dusk_offset) = (3, 3);    # in minutes towards noon
                                             # values >= 3
my $script = "perl /home/user/foo/bar/on-off.pl";

# dawn
`echo "$script two day"    | at $dawn + $dawn_offset minutes 2> /dev/null`;
# $dawn_offset++;
`echo "$script one day"    | at $dawn + $dawn_offset minutes 2> /dev/null`;
$dawn_offset += 1;
`echo "$script two status" | at $dawn + $dawn_offset minutes 2> /dev/null`;
# $dawn_offset++;
`echo "$script one status" | at $dawn + $dawn_offset minutes 2> /dev/null`;

# dusk
# need a space after minus/hyphen "-" sign
`echo "$script one night"  | at $dusk - $dusk_offset minutes 2> /dev/null`;
# $dusk_offset--;
`echo "$script two night"  | at $dusk - $dusk_offset minutes 2> /dev/null`;
$dusk_offset -= 1;
`echo "$script one status" | at $dusk - $dusk_offset minutes 2> /dev/null`;
# $dusk_offset--;
`echo "$script two status" | at $dusk - $dusk_offset minutes 2> /dev/null`;
on-off.pl

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;

# usage: ./on-off.pl [one | two] [day | night | status]

my $camera  = $ARGV[0] // "";    # ensure these two arguments are not undefined
my $command = $ARGV[1] // "";    # accepts invalid arguments

# CGI scripts specific to Axis M3025-VE Network Camera
# https://www.axis.com/files/manuals/um_m3025ve_60325_en_1410.pdf
my $update = "?action=update&root.ImageSource.I0.DayNight.IrCutFilter";
my $status = "?action=list&group=root.ImageSource.I0.DayNight.IrCutFilter";

my $filename = "/home/user/foo/bar/zm_day-night.log";
open my $FH, '>>', $filename or die "error trying to append: $!";

my ($which, $http);
if ( $camera eq "one" ) {
    $which = "this_one";
    $http = "http://root:password\@this_camera/axis-cgi/param.cgi";
    # need to escape character @ in perl
} elsif ( $camera eq "two" ) {
    $which = "that_one";
    $http = "http://root:password\@that_camera/axis-cgi/param.cgi";
}

my ($message, $output);
if ($command eq "day") {
    $message = "  $which IR Filter is ON  : ";
    $output = `curl -s --request GET '$http$update=yes'`;
} elsif ($command eq "night")  {
    $message = "  $which IR Filter is OFF : ";
    $output = `curl -s --request GET '$http$update=no'`;
} elsif ($command eq "status") {
    $message = "  $which IR Filter status = ";
    $output = `curl -s --request GET '$http$status'`;
    $output =~ m/=(\w+)$/;
    $output = $1;
}

my $date = `date`;
chomp $date;
print $FH $date, $message, $output, "\n";
# didn't trap errors on mulformed variables $camera, $command

close $FH;
Sample log

Code: Select all

Sat 29 May 20:48:00 PDT 2021  that_one  IR Filter status = no
Sat 29 May 20:48:00 PDT 2021  this_one  IR Filter status = no
Sun 30 May 05:18:02 PDT 2021  that_one  IR Filter is ON  : OK
Sun 30 May 05:18:02 PDT 2021  this_one  IR Filter is ON  : OK
Sun 30 May 05:19:00 PDT 2021  that_one  IR Filter status = yes
Sun 30 May 05:19:00 PDT 2021  this_one  IR Filter status = yes
Sun 30 May 20:47:01 PDT 2021  that_one  IR Filter is OFF : OK
Sun 30 May 20:47:01 PDT 2021  this_one  IR Filter is OFF : OK
Sun 30 May 20:48:01 PDT 2021  that_one  IR Filter status = no
Sun 30 May 20:48:01 PDT 2021  this_one  IR Filter status = no
Ta.
Post Reply