Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Night vision distance #182

Open
4c1d8urn-eh opened this issue Jul 5, 2017 · 24 comments
Open

Night vision distance #182

4c1d8urn-eh opened this issue Jul 5, 2017 · 24 comments

Comments

@4c1d8urn-eh
Copy link

4c1d8urn-eh commented Jul 5, 2017

screenshot_20170706-015212
Hi i have a problem with Night vision. in discription for XiaoFang is 9m but when my camera goes to night vision i don't see anything. My room has 5m width.
Do i can regulate IR power in config?

@wekii
Copy link

wekii commented Jul 6, 2017

It looks that you have camera with broken IR lights.

@4c1d8urn-eh
Copy link
Author

4c1d8urn-eh commented Jul 6, 2017 via email

@wekii
Copy link

wekii commented Jul 6, 2017

Do you hear "click" when camera turns on or off night vision?

@4c1d8urn-eh
Copy link
Author

Yes i hear specyfi click when camera goes to night Mode and 2 IR led is then blink
img_20170706_145537

@wekii
Copy link

wekii commented Jul 6, 2017

Then I don't have any idea what could be a problem.
Is this camera hacked?

@4c1d8urn-eh
Copy link
Author

4c1d8urn-eh commented Jul 6, 2017 via email

@samtap
Copy link
Owner

samtap commented Jul 6, 2017

Based on the first pic, I'd say the IR LEDs are off but the 2nd pic clearly shows they're on... If power supply is lacking LEDs will be not as bright. But maybe you're expecting too much of it, two leds are really not capable to reach 9mtrs (but they should be able to light your room, at least a couple of meters directly in front of the lens)

@4c1d8urn-eh
Copy link
Author

4c1d8urn-eh commented Jul 6, 2017 via email

@wekii
Copy link

wekii commented Jul 6, 2017

Did you had the same problem before hacking the camera?

@4c1d8urn-eh
Copy link
Author

4c1d8urn-eh commented Jul 6, 2017 via email

@wekii
Copy link

wekii commented Jul 6, 2017

Maybe you meant to say that you can not run camera outside China ?
In wich country do you live?

@4c1d8urn-eh
Copy link
Author

4c1d8urn-eh commented Jul 6, 2017 via email

@wekii
Copy link

wekii commented Jul 7, 2017

Maybe you should try to remove hack to see if there's any difference.
You can use camera in Poland, but only when you are connected on you local wifi.
#122 (comment)

For connection from outside of your LAN you need to have xiaomi router.

UPDATE
Today I got Xiaomi Mi Router 3 and I can confirm that you still can NOT connect on XiaoFang camera (unhacked) when mobile phone is on 3G/4G.

@louis-lau
Copy link

@samtap There's definitely something going on related to the hacks.

This is a pic (from the rtsp stream) with cloud apps completely disabled:
cam 2 - 2017-08-01 02 32 05

This is a pic (from the rtsp stream) with cloud apps disabled after boot with the stop-cloud script:
cam 2 - 2017-08-01 02 28 02

As you can see with cloud enabled the picture becomes fuzzier, but brighter.

@davidjb
Copy link
Contributor

davidjb commented Sep 9, 2017

I'm seeing the same result with my cameras as @louis-lau's results. With the hacks enabled the visible distance is incredible short, unfortunately making the cameras unusable in the dark. Suggestions of things to try would be great; otherwise I'll start poking around in the camera.

@BlaY0
Copy link

BlaY0 commented Sep 19, 2017

I'm still analyzing this camera, I've just got it... My guess is that there are some camera host driver setting exposed through /proc/isp which are changed on iCamera app start. Check if there are any differences in those proc handle files between cloud-on and cloud-off mode.

@davidjb
Copy link
Contributor

davidjb commented Sep 19, 2017

I diff'ed all the parts of /proc/isp over the last few days and found that /proc/isp/af/w0-sum notably different. With cloud apps enabled, the value is around 0x450 and cycles between 0x300 and 0x500. However, with cloud apps disabled, this value is steadily increasing over time.

Tonight, it started around 0xf4fa and has moved upwards and occasionally downwards, now being 0x9512 and still going. I wonder if this correlates with the fact that I'm visibly seeing the night vision getting worse the longer the camera is on. With cloud apps disabled, the camera started from cold boot with excellent IR -- the majority of my room was visible, and now at almost 30 mins later, it's almost entirely black. I can see the change slowly happening on the video stream and the AF W0-SUM values keep increasing (eg snx_isp_ctl --afget-sum -?). What does this value represent and is it possible to set or affect that value? snx_isp_ctl only has the ability to get/poll the value.

Otherwise, in the diff, I saw that /proc/isp/iq/nrn changed from 1 (with cloud apps) to 0 (without). Anyone know what /proc/isp/iq and /proc/isp/iq/nrn or /proc/isp/iq/nra are? Changing the settings seems to have little to no discernible difference. Also, /proc/isp/osd/1/{height,width} get adjusted but I doubt that's it; and the same with lots of various parts of /proc/isp/md/* for Motion Detection.

@halfluck
Copy link

@davidjb i'm impressed with your progress, it really seems like you might find an answer to this annoying issue.

I've been rebooting my cameras manually every night time, which i believe kicks in iCamera on boot, this works really well for me and the IR mode stays stable and vision is good.

Has anyone tried a simple bandaid hack to fang-ir-control.sh that does a /sbin/reboot on Day Stare Change? this would save me from manually rebooting.

Thanks Rob.

@halfluck
Copy link

halfluck commented Sep 21, 2017

for anyone that wants a quick fix for now, this is what I am doing

#!/bin/sh

echo "IR Reboot script started"

DAY="$(gpio_aud read 2)"
    if [ $DAY -eq 1 ]
    then 
        echo "Daytime"
        IR_ON=0
    else
        echo "Its Dark"
        IR_ON=1
    fi

while :
do
        DAY="$(gpio_aud read 2)"
        if [ $DAY -eq 1 ]
        then
                if [ $IR_ON -eq 1 ]
                then
                        echo "It was Dark Now Its Daytime so Reboot"
                        /sbin/reboot
#                        IR_ON=0
                fi
        else
                if [ $IR_ON -eq 0 ]
                then
                        echo "It was Daytime Now Its Dark so Reboot"
                        /sbin/reboot
#                        IR_ON=1
                fi
        fi
        sleep 3
done

@samtap
Copy link
Owner

samtap commented Sep 21, 2017

It's quite silly to reboot and rely on iCamera to setup the hardware. Can't anybody figure out what iCamera does and the ir script doesn't do? Run something like find /proc/isp -type f -print -exec cat {} ; will print all isp settings.

@BlaY0
Copy link

BlaY0 commented Sep 21, 2017

@samtap there are no differences in /proc/isp in both modes, @davidjb already tried that...

There's already a difference in quality if you power-on your camera when there's already dark. If you power it on during the day or when the lights are on, then when turning the lights off you get more grainy/noisy image. That's even with iCamera initialization.

So hacks enabled, cloud enabled, cloud apps stopped and powering camera on in the dark will give you good results (a little bit blurry/fuzzy image but without noise) and low bandwidth usage (under 100 kbps in 720p) while rtsp streaming. More grainy/noisy image gives you bigger bandwidth usage tho.

I played a little bit in cloud disabled mode, fiddling with sensor exposure and gain (with ISP AEC and AWB disabled) and I actually managed to get more light but wasn't able to reduce noise (the noise was horrible) thus bandwidth went haywire (from let say 300 kbps to 2500 and even more on a bw 720p image).

The next thing I'm planning to do is stracing that iCamera stuff...

@BlaY0
Copy link

BlaY0 commented Sep 25, 2017

OK, stracing didn't get me anywhere but I have found few starting points after that...

That /proc/isp/iq/nrn is actually quite important. That iq handles control image quality sub module and nrn is actually enabling some sort of fuzzy/blury overlay so the image gets smoothened which is good for the low bitrate. As I said, more noise gives you way higher bitrate which just means bigger file or more bandwidth used without any quality gain.

Then there are handles for auto exposure submodule in /proc/isp/ae dir and these are adjusting automatically depending on intensity of the light source(s). But you can still play around with for example gain and as soon as you change the value of it, you see the result. At that point ae submodule is disabled even tho the enable handle still shows 1. If you want ae back, you have to disable it again via handle and then reenable it.

@masterchop
Copy link

no solution to this?

@frol
Copy link

frol commented Aug 14, 2018

I have the same problem, but I have two XiaoFang cameras and I clearly see that they have a drastic difference in IR lights.

Here is what I have:

  • Two XiaoFang cameras:
  1. non-banned (with a hole Setup button), which I own for over 2 years now, and it has poor night picture quality.
  2. banned for use outside of China (with a push-button Setup button), which I got about a year ago, and it has great night picture quality.
  • fang-hacks with Cloud apps auto-stopped after a boot for both cameras, and in fact, I even tried using one SD card for both of the cameras to ensure that I have identical setup.
  • I have additionally applied patches for fang-ir-control from @davidjb (namely, /proc/isp/iq/nrn gets set to 0x1 for night mode).

The older camera produces the type of picture shown in the first message in this thread. When I replace the first camera with the second one, I get a perfect picture. Next, I powered on both cameras and the older camera started producing a great quality night vision picture as well and I can see that IR light goes from the second camera (I can see a flashlight effect on the video from my old camera when I turn my newer camera). The old camera still has its IR indicators on and even can light some items in a range of less than 1 meter (while the newer camera lights up the whole room which is ~3x4 meters).

It looks like a hardware problem and IR lights in my old camera just die. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants