openipcamera / openipc-firmware

OpenIPC Firmware for Wyze Cameras
https://openip.cam
894 stars 129 forks source link

Implementing Auto Night Mode #70

Closed manianac closed 3 years ago

manianac commented 6 years ago

Forgot to mention this is for the v2. Currently I've replaced ldr.sh with a simple script that checks the current time, and enables/disables night mode.

I started brainstorming pulling a current image of the camera feed, and checking for a percentage of dark pixels versus white/oversaturated pixels.

I've never missed around though with a busybox embedded device, is there a way I can pull video0 and analyze the picture at that time? I'm more for brainstorming ideas rather than just asking for a solution.

chriscrowe commented 6 years ago

@manianac Do you mind sharing your script that uses day/night timing?

manianac commented 6 years ago

Sure, its not robust at all, the hours I hard-coded as a quick mock-up, but it works.

#!/bin/sh

. /system/sdcard/scripts/common_functions.sh

#set -ex #Debugging

while true; do
  H=$(date +%k)
  if [ $H -lt 6 ]; then
    night_mode on
  elif [ $H -ge 23 ]; then
    night_mode on
  else
    night_mode off
  fi

  sleep 10
done
manianac commented 6 years ago

I can say I can get the image with /system/sdcard/bin/getimage, now I need to work on how to process it. I have a feeling the RTSP server is taxing the cpu enough (camera is hot, constant 80% cpu usage), so I may have to offload processing elsewhere. In that case I'll have to rig up a way for my central server to signal the camera to enable/disable night mode.

chriscrowe commented 6 years ago

I'm actually in the process of setting up Home Assistant... I was thinking about ways to use this for automation-- perhaps even use my Hue Motion sensor (which has light and temperature sensors built in) to trigger the night mode... Just trying to get creative.

manianac commented 6 years ago

Personally I'm using motioneyeos, so i need to find some command-line way to do it. I am still amazed the image quality difference when using the official wyze app, as well as their night mode algo must be server-side.

chriscrowe commented 6 years ago

FWIW I find that I get better resolution when using Dafang-Hacks firmware

manianac commented 6 years ago

Interesting, I see that one has a lot more improvements, I just haven't been able to get it to run on my v2's. Definitely have to look into it still

chriscrowe commented 6 years ago

Ran first try in my v2, easier than Openipc in fact

manianac commented 6 years ago

Which cfw did you use? 1.0 or 1.1?