Infrared focus shift - explanation

Discussion in 'Dahua' started by wopi82, Nov 9, 2017.

Share This Page

  1. wopi82

    wopi82 Getting the hang of it

    Joined:
    Feb 9, 2017
    Messages:
    19
    Likes Received:
    49
    Location:
    Poland
    While reading the forum's threads, I found some posts with complains about soft image while the camera is going from color to IR or the opposite. In this Testing roundup IPC-HDBW4431EP-AS versus IPC-HDBW5431E-Z thread, TVT73 is complaining about soft focus in IPC-HDBW4431EP-AS camera. Here Any Dahua cams WITHOUT the focus bug? Jeroen1000 is calling this a "focus bug".

    In reality this is not a "bug" or any firmware/hardware error. It's just physics of electromagnetic waves, and every camera with removable IR filter, without advanced optics will experience this focus shift to some extent.

    IR_lens_diagram-936x1024.jpg

    When visible light passes through the camera's lens, the focus plane overlays precisely with image sensor, and so the image is sharp. The infrared light passing the same lens, focuses tiny bit further from the lens and thus the image becomes blurry. The final night image consist of a mixture of visible and infrared light. And so different objects on the image may look more or less out of focus, depending on how much IR light is being reflected from them. Below is an example from my HDW4231EM-AS camera.

    IR_vs_color.jpg

    The tree branches as well as bushes are noticeably blurry in night mode, but the inside of the car look almost identical between two modes.

    Owners of fixed lens cameras have no chance to fix this, as there is no autofocus available. However varifocal cameras can refocus and correct this shift. It would be a pain in the butt to do that every twice a day, but it is possible. The best solution is to use ultra low dispersion lens, but these are expensive and would rise the overall cost of the camera.

    Anyway, I thought it will be useful to share this info with you. For further reading go to:
    Resolving the Problem of Focus Shift - CCTV Information
    IR Corrected vs. Standard Lenses: Chromatic Aberration | OEMCameras.com Blog
     
    weigle2, adamg, Q™ and 9 others like this.
  2. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    I appreciate you taking the time explaining this in more detail. Kudo's! It is certainly useful.

    However, a fix is pretty easy! When the camera switches from day to night or the other way around, you can make it go to a *stored* focus value. Do note the fact it goes to a stored value. It does not perform a full autofocus cycle. This operation takes about a second on my cams. So I do get you saying it is not a bug, but at least it is just sloppy programming:). I do consider it a firmware error because of that.
     
    TVT73 likes this.
  3. wopi82

    wopi82 Getting the hang of it

    Joined:
    Feb 9, 2017
    Messages:
    19
    Likes Received:
    49
    Location:
    Poland
    Thank you Jeroen1000 for the info. I did't know there is such an option. My camera is only fixed lens. What do you mean by programming? Is it some kind of script? Can it be done by Dahua's own software? If not, than what software you use?
     
  4. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    It is using the CGI-interface. I've attached the PDF for reference. You can thus send the camera the focus value using HTTP and it will change its focus to that value.
    However, there is not an accurate enough trigger. The exact moment for D/N switching depends on the kind of day: cloudy, sunny, well you get the point. The best you can do is a fixed hour for camera's that are in the same lighting position all night.

    Have a floodlight? Well too bad, you cannot react to a floodlight on off event using time programming. It is possible using sensors and triggers however, this is super easy to solve with firmware. I don't know why Dahua has not been doing this since...day 1. It's just a tiny amount of code tied to the code that makes the camera decide to switch to color or monochrome.

    If they do not want to program this, they should use IR-corrected lenses but since the picture gets blurry I assume they are not using those. Can you focus your camera's using the GUI since they are fixed? Or does it require a ladder:)
     

    Attached Files:

  5. wopi82

    wopi82 Getting the hang of it

    Joined:
    Feb 9, 2017
    Messages:
    19
    Likes Received:
    49
    Location:
    Poland
    A ladder :) In fact, there is no way to fix that in fixed-lens version. I have to live with that and get used to it. I was thinking about buying fixed lens IPC-HDW4631EM-ASE. Right now I have a dilemma between this one and varifocal IPC-HDW5631R-ZE. IPC-HDW4631EM-ASE is cheaper (I will not use zoom), due to IR/LENS separation there is no IR reflection in the glass. However, the higher the resolution, the more you see this focus shift. At 2 megapixels (fullHD) it is noticeable, but not so distracting. At 6 megapixels it will be annoying. And so, I am wondering between these two models, because varifocal has an autofocus and slightly brighter lens.
     
  6. tangent

    tangent Known around here

    Joined:
    May 12, 2016
    Messages:
    1,592
    Likes Received:
    681
    In addition to varifocal cameras, fixed cameras with auto back focus (ABF) can adjust for this slight shift.
     
  7. wopi82

    wopi82 Getting the hang of it

    Joined:
    Feb 9, 2017
    Messages:
    19
    Likes Received:
    49
    Location:
    Poland
    True, but it is available mostly in box cameras, with interchangeable lenses.
     
  8. wopi82

    wopi82 Getting the hang of it

    Joined:
    Feb 9, 2017
    Messages:
    19
    Likes Received:
    49
    Location:
    Poland
    I thought it would be interesting to see a direct comparison of an object illuminated by IR light and visible light. I took my Xblitz Night dashcam with IR LEDs and a torch to see the difference. I wanted to use some well defined object so that the difference would be well seen.

    IR-vs-visible.jpg

    This is me, with some Christmas decoration :) These are 1:1 crops from a full view. The middle one is definitely more blurry than the right one. This means that if you have a scene, where part of it is illuminated by let say IR reflector and the rest is some artificial visible light, refocusing may not resolve the problem, because focusing to IR illuminated part will defocus the rest and vice versa. If the scene is fully illuminated by IR than no problem, but in case of mixed illumination, the best solution is UD lens.
     
    adamg, cb8 and bigredfish like this.
  9. TVT73

    TVT73 Getting the hang of it

    Joined:
    Aug 29, 2016
    Messages:
    383
    Likes Received:
    89
    Location:
    Germany
    It´s really frustrating, as I comment this issue since over half an year and for autofocus cams it´s really simple to be solved with a little firmware modification.

    Unfortunately dahua´s engineer seems to give a dam on it, several tries through different selling channels has got no result in this. In fact a 2mp cam is much less affected than a 4mp or higher, and due to this I can´t recommend to buy those cams, if night view with IR is necessary.
    Interestingly for fixed focus 4mp ones I can´t see the night focus issue. It has maybe to do with a different infinity focus point and the higher aperture.

    I am hopeless, that a firmware fix will ever arrive. If you have a look on how dahua behaves on firmware issues, you all would know why I am thinking this. My issue list is growing and most of them are unsolved for ever. (Day/Night profileswitching by ambient light, nvr 4xxxx - 4ks2 and 5xxx - 4ks2 profile switching sheduler is lost, IVS tripwire fails when lines are too near the outer side of picture, manual shutter control is broken when using an nvr, for speaking of only the most burning ones for me ) And yes, I have documented them well, with step by step issue log and screencasts ...

    For that there is no misunderstanding, Dahua is selling a good hardware for an affordable price, many main parts are working very well. But if you are running into an issue and hope to get an solution from dahua, you are lost :(
    This is maybe a price tag reason. And the engineers has done (a good job) in fixing the last several upcoming security issues, so that there are no resources of man power left :rolleyes:

    Here some of my conversations about it...

    and further more from technical support:
     
  10. imog

    imog n3wb

    Joined:
    Dec 5, 2016
    Messages:
    17
    Likes Received:
    4
    Worth noting this focus value isn't available on some cameras, for example the PTZ sd49225t-hn. It's a big issue for switching daytime/nighttime, as the only focus adjustments are relative, which is really difficult to dial in vs an absolute setting.
     
  11. bp2008

    bp2008 Staff Member

    Joined:
    Mar 10, 2014
    Messages:
    5,584
    Likes Received:
    2,250
    The first IR camera I ever got (not Dahua) had it way, way worse than this. It was manual varifocal of one of those Chinese brands that is there one day and gone the next. Not only was it impossible to have it well-focused across the entire field of view at once, but it wasn't IR-corrected at all so you could focus it for visible light or IR but not both.

    I still have the old screenshots:

    [​IMG]

    [​IMG]

    Dahua cameras by comparison do very well, even with fixed focus lenses.
     
  12. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
  13. imog

    imog n3wb

    Joined:
    Dec 5, 2016
    Messages:
    17
    Likes Received:
    4
    I appreciate the perspective. That said, I am disatisfied that a $350 Dahua varifocal needs refocused for daylight/IR. Admittedly I'm not qualified to know what to expect, but both my hik ds-2cd2t42wd-i8 have no apparent focus issues with switching and cost less than half as much so I guess that was my baseline. This was probably foolish, as the use case is completely different - the Dahua sd49225t-hn doesn't have an issue if autofocus is enabled and the scene is reasonably lit. But configured to read license plates at 150ft at night it has a big issue - not enough light for autofocus to function.

    But I'm asking too much also. This camera is a great deal for what you get in a PTZ and the images it gets of plates are excellent when properly dialed in - despite being at high distance and not an ideal angle and at night. I'm just working on how to dial in the focus consistently in an automated fashion. It's super easy to use the http API, just missing the adjustFocus API element on this model.
     
  14. imog

    imog n3wb

    Joined:
    Dec 5, 2016
    Messages:
    17
    Likes Received:
    4
    I don't have any reason to think that is the case. Furthermore, my requirement is very specific which won't affect most use cases for a PTZ - I am almost at max zoom, capturing license plates at night on moving vehicles about 150ft away. Works great when focussed properly, IR maxed, HLC at 70, shutter at 1/725, everything else default. That means I am capturing nearly pure blackness at night, until I see plates or headlights, then it's perfectly clear (with focus set manually). This also means autofocus isn't an option - once it switches to the night profile, it can't autofocus as the scene is too dark.

    Plenty of other Dahua models that support adjustFocus code in the API. So if your use case is like mine, then you need to verify that model supports that adjustFocus API code. And if it does, then it's easy to set an absolute focus to ensure its always in focus for your set of conditions. If you have a reasonably lit night scene, either via IR or ambient, then autofocus will work fine for you.
     
  15. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    Since this is the focus thread something has come to my attention. I can find a fair amount of suggestions, telling to focus at "near" dark to compromise on the focus shift. The goal is to have the iris open the aperture fully of close to full.
    Apparently, focussing in bright weather circumstances will make focus shift worse when you use IR at night?

    I also read you must do this when the camera IR is OFF and when it is in full color mode? Can anyone explain the reasoning behind this? Why in color with IR off?
     
  16. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    I think I somewhat understand it now. The focus shift we are talking about here is longitudinal chromatic aberration. A lens cannot focus all colours in the same plane in the longitudinal direction: see graphical representation (red coloured section of the graphic) in the opening post. Net result: image a bit out of focus = slightly blurry.

    Because the IR-wavelength(s) differs a lot from the wavelengths of visible light, we notice this effect best when lighting with IR-light vs visible light.

    We have 2 options to fix it:

    1) Refocus when IR-light goes on and off (the solution I Want from Dahua)
    2) Use an IR-corrected lens
    * Or do both for the very best result:)

    So I'm not sure the advice telling you to focus at near dusk in colour before the IR-lights activate does anything at all to mitigate the longitudinal chromatic aberration.

    That advice is for something else. Apparently, if the you focus with the aperture fully open at "night" (it just needs to be dark enough for the aperture to open fully), your depth of field will be better during daytime or something. I'm still trying to connect the dots
     
    Last edited: Nov 16, 2017 at 8:20 AM
  17. adamg

    adamg n3wb

    Joined:
    Sep 19, 2017
    Messages:
    22
    Likes Received:
    4
    I've had Pelco tell me that they recommend focusing their manual focus/zoom cameras in dark daylight conditions rather than bright daylight conditions. Or, if it is bright conditions and I need to focus, to put a dark welder's shade lens in front of the camera so it sees a darker image, causing it to open its iris to max. Somehow this leads to the best focus for all conditions. Curious to learn if this is this open iris concept is the same reasoning as the IR wavelength focus problem.
     
  18. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    I don't believe it is the same. The "open iris" thing is preserve depth of field during nightime. If you focus during daytime (on a bright day) the aperture hole is very small = large DOF. When night comes, the aperture opens up and the DOF decreases. To migitate that, it seems you have to focus with the aperture close to fully open or fully open.

    The IR-blur can be fixed using my 2 suggestions and is an other problem.
     
  19. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    The proof is in the pudding:)
    - Scenario: I have focussed the camera 30 minutes before it would switch to B/W itself. Then, at full darkness I took 2 photo's.
    1) 1ste one has been made before refocussing the camera for IR-light.
    2) the 2nd has been made after refocussing the camera for IR-light.

    Tips to see the difference. Switch pictures to full screen and flip between them on a 1080p screen laptop. Do not view them slightly minimised side by side. You might miss the point.

    All this can be solved by a simple firmware tweak!

    19u18_16-11-2017_BEFORE_FOCUS.jpg
    19u18_16-11-2017_after_FOCUS.jpg
     
  20. TVT73

    TVT73 Getting the hang of it

    Joined:
    Aug 29, 2016
    Messages:
    383
    Likes Received:
    89
    Location:
    Germany
    First of all, I didn´t see this problem on any ptz cam of dahua. They have a different autofocus function. But I only tested at max 2mp ones. The upcomming new 4MP SD Mini PTZ is maybe one candidate for having the same issues. My 2MP cams are working well.

    It´s no difference when we do the refocusing at day and night view.
    If we look on the focus value from web interface I can´t see a difference for refocusing all day long. It´s always the same value.

    If we use only color mode it´s not necessary because of the missing ir cut and there is no chromatic aberration and only visible light.

    with jeroen1000 pictures its very good to see, I don´t need to switch to full screen view or zoom in. It´s a 4mp one I mean.

    I agree, a simple firmware trick will solve it and we would get a perfect picture also at night. Fore this reason I spend numerous hours in discussing it with dahua. It´s the same as the were not able to combine a switch for day/night profile to ambient light, what is is a normal behaviour for every other manufacturer of ipcams I ever used.
     
  21. Jeroen1000

    Jeroen1000 Young grasshopper

    Joined:
    Sep 26, 2016
    Messages:
    42
    Likes Received:
    10
    So part 1 left us focussing at night time with IR ON.
    Now I took a new set of pictures during daytime:

    - Scenario: Camera was focussed at night time with IR-ON.
    1) 1ste one has been made during daytime before refocussing the camera
    2) the 2nd has been made during daytime after refocussing the camera
    Daytime before refocus.jpg
    Daytime after refocus.jpg
    As you can see, the difference for day time is totally unacceptable. I will be contacting Dahua again to complain.
     
    Last edited: Nov 17, 2017 at 6:03 AM
  22. imog

    imog n3wb

    Joined:
    Dec 5, 2016
    Messages:
    17
    Likes Received:
    4
    I nailed this down for myself, addressing the focus shift issue on the sd49225t-hn which doesn't support the adjustfocus api setting to set an absolute focus value.

    To switch modes I'm doing it externally thru a script from my Vera home automation, but any method you want to use to send the API calls would work fine. My home automation is already figuring out when day/night is every day, so its easy to use that as a trigger when I need to switch modes.

    First, I turn on night mode/IR on (VideoInMode[0].Config[0]=1), set focus to automatic (VideoInFocus[0][1].Mode=2), and shutter to 1/1 (&VideoInExposure[0][1].Value1=1000&VideoInExposure[0][1].Value2=1000) so that the scene is very well lit/clearly visible - this gets the camera in night mode, with IR on, and autofocus works great since the scene is well lit with long shutter.

    http://username:password@192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1&VideoInFocus[0][1].Mode=2&VideoInExposure[0][1].Value1=1000&VideoInExposure[0][1].Value2=1000

    So that gets my focus reset to account for the IR focus shift going from daylight to night, however my shutter is way too long to capture plates now. So I have the script sleep for a few seconds ensuring it has time to apply the prior settings and focus, then I just need to set focus to manual (VideoInFocus[0][1].Mode=4) so it doesn't try to auto-adjust again once the scene goes black, and I set shutter to 1/1000 (&VideoInExposure[0][1].Value1=1&VideoInExposure[0][1].Value2=1)which is perfect for clear, crisp plates:

    http://username:password@192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1&VideoInFocus[0][1].Mode=4&VideoInExposure[0][1].Value1=1&VideoInExposure[0][1].Value2=1

    My daytime switch just turns on day mode and sets focus and shutter to automatic:

    http://username:password@192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0&VideoInFocus[0][0].Mode=2&VideoInExposure[0][0].Mode=0

    So to recap, I'm using these settings with the SD49225T-HN to capture plates at 150' day and night at something like a 40 degree angle. During the day, everything is set to default except zoom near max. During the night:
    picture is set default
    exposure is set manual, shutter 1/1000, 2D/3D NR set to 26
    Backlight HLC set to 71
    WB auto
    Day/Night - ICR black and white
    Zoom focus set to manual
    IRLight far set 100

    Night plates:

    [​IMG]

    Day plates:

    [​IMG]