Dahua Visit

Problem with that is that it would probably also need internet access to calculate or retrieve the correct times every day.
No, you don't. You only need access to a time server to set the camera time. You can run a local time server on a computer if you don't want your cameras to have access to an Internet time server.

The formula for calculating sunrise and sunset from latitude and longitude is surprisingly simple, which I learned when I programmed it into my Camscript software. You need some basic math and trigonometry, and the local time. The result is accurate to within one minute.
 
For those who are curious, here is the basic function in AppleScript for calculating sunrise and sunset times given latitude, longitude, and time of day. I adapted it from this document published by the NOAA.

____

-- Function to determine sunrise and setset times (in seconds) given latitude and logitude

on sunrise_sunset(lati, longi)

-- Query 'date' command for time zone. Convert time zone information into an offset specified in hours.

set timezoneoffset to do shell script "/bin/date +%z" as string

set hoursadjust to (first character of timezoneoffset) & (second character of timezoneoffset) & (third character of timezoneoffset) as number

set day_of_year to dayofyear()

set currentyear to (do shell script "/bin/date +%Y") as number

-- Calculate sunrise and sunset times in seconds. The following algorithm is accurate to within one minute without the need to query an external web service.

set days_in_year to 365

-- Check for leap year

if (currentyear mod 4) = 0 then
if (currentyear mod 100) is not equal to 0 or (currentyear mod 400) = 0 then set days_in_year to 366
end if

-- Calculate fractional year in degrees

set fractionalyear to 360 / days_in_year * (day_of_year)

set eqtime to 229.18 * (7.5E-5 + 0.001868 * (cosine_of(fractionalyear)) - 0.032077 * (sine_of(fractionalyear)) - 0.014615 * (cosine_of(2 * fractionalyear)) - 0.040849 * (sine_of(2 * fractionalyear)))

set decl to 0.006918 - 0.399912 * (cosine_of(fractionalyear)) + 0.070257 * (sine_of(fractionalyear)) - 0.006758 * (cosine_of(2 * fractionalyear)) + 9.07E-4 * (sine_of(2 * fractionalyear)) - 0.002697 * (cosine_of(3 * fractionalyear)) + 0.00148 * (sine_of(3 * fractionalyear))

set decl to 180 * decl / pi

set x to cosine_of(90.833) / (cosine_of(lati)) / (cosine_of(decl)) - tan(lati) * (tan(decl))

set ha to arccos(x)

set sunrise_time to round (60 * ((720 - 4 * (longi + ha) - eqtime) + (60 * hoursadjust)))

set sunset_time to round (60 * ((720 - 4 * (longi - ha) - eqtime) + (60 * hoursadjust)))

return {sunrise_time, sunset_time}

end sunrise_sunset
 
It will take more memory though. It'll be a tradeoff of other capabilities I would guess. On top of that, if the camera has access to a time server, and let's assume it's a local time server, and you run a script like yours or Sunrise/Sunset on Windows it doesn't use any camera resources at all and is barely noticeable on the VMS machine.
 
On the software side, please tell the engineers they need to update the camera firmware so that the user can enter the latitude and longitude to automatically switch between Day and Night profiles according to local sunrise and sunset times.
This will be nice.. As I do have a friend who runs a NVR and will be nice if Camera can switch profile based on Geo location and Sunset/Sunrise ...

He has no computer which runs 24/7 where I can set a Dahua Sunset Sunrise software...
 
  • Like
Reactions: JDreaming
It will take more memory though. It'll be a tradeoff of other capabilities I would guess. On top of that, if the camera has access to a time server, and let's assume it's a local time server, and you run a script like yours or Sunrise/Sunset on Windows it doesn't use any camera resources at all and is barely noticeable on the VMS machine.
The issue isn’t resources, it is convenience. Right now you have to set up some sort of third-party software in order to switch the camera profiles at the right time. It’s simply a pain to do, when the camera could easily do it itself.

I have a couple of “dumb” programmable light switches from 15 years ago that do the same thing, although you have to keep adjusting the time to keep them working properly. The amount of memory required is really insignificant by modern standards.
 
I'm not so sure about that memory issue. Cameras aren't like a PC in that respect.
 
It just doesn't rate high on my list of things. Improved night performance is a little more important at least to me. Installing and running Sunrise/Sunset is trivial.
 
It just doesn't rate high on my list of things. Improved night performance is a little more important at least to me. Installing and running Sunrise/Sunset is trivial.
It certainly matters to me, and many others. Optimizing camera settings for day vs. night is fairly essential for LPR, among other things. I think that Dahua would find a very favorable response to such a function. The memory and computational costs would be minimal in modern cameras.
 
It certainly matters to me, and many others. Optimizing camera settings for day vs. night is fairly essential for LPR, among other things.
I agree that optimizing cam settings for day vs. night is important. But I use the Sunset/Sunrise utility and would prefer that Dahua use their time on other improvements.
 
  • Like
Reactions: JDreaming
No, you don't. You only need access to a time server to set the camera time. You can run a local time server on a computer if you don't want your cameras to have access to an Internet time server.

The formula for calculating sunrise and sunset from latitude and longitude is surprisingly simple, which I learned when I programmed it into my Camscript software. You need some basic math and trigonometry, and the local time. The result is accurate to within one minute.
Trigonometry :oops:, rules me out:winktongue::rofl:
 
Is there a solution for Sunrise/Sunset Ex. small devices which we can deploy and which is easy to configure and setup like the Raspberry pi or similar ? To make camera switch profile based off gelocation sunset/sunrise for people who don't want to run a dedicated computer for this or do not have a computer and only have an NVR ?

I just have not setup Raspberry pi or similar device so not sure how or if that can work...

Sounds like the one @biggen posted can run on Raspberry possibly Not sure how complex or simple is it gonna be to setup and which raspberry to get ?
 
Is there a solution for Sunrise/Sunset Ex. small devices which we can deploy and which is easy to configure and setup like the Raspberry pi or similar ? To make camera switch profile based off gelocation sunset/sunrise for people who don't want to run a dedicated computer for this or do not have a computer and only have an NVR ?

I've been meaning to do that using ESPEasy, which is open source firmware that runs on inexpensive ($10) ESP8266 and ESP32 WiFi devices.

ESPEasy has sunrise/sunset variables and a text based rule engine that can send http commands. So a single ESPEasy device could update settings on several cameras. The only caveat is that the cameras would need to be on the same local network as the ESPEasy device.

I haven't attempted to do this yet because too many projects are in the way. But it's on the honey-do list as a winter project. Maybe someone else will try it out and share what they did.

BTW, I don't want to derail Andy's discussion. So if there is interest in this then just click this post's "Like" button instead of posting here. If the interest is high enough I'll create a topic with an example on how to do it.

- Thomas