How to detect moving object in varying light(illumination) conditions due to clouds - openCV
I have been trying to detect moving vehicles. But due to varying light conditions because of clouds, (not shadows of clouds, just illuminations) the background subtraction fails.
I have uploaded my input video here --> Youtube (30secs)
Here is what I got using various available background subtraction methods available in opencv
import numpy as np
import cv2
cap = cv2.VideoCapture('traffic_finalns.mp4')
#fgbgKNN = cv2.createBackgroundSubtractorKNN()
fgbgMOG = cv2.bgsegm.createBackgroundSubtractorMOG(100,5,0.7,0)
#fgbgGMG = cv2.bgsegm.createBackgroundSubtractorGMG()
#fgbgMOG2 = cv2.createBackgroundSubtractorMOG2()
#fgbgCNT = cv2.bgsegm.createBackgroundSubtractorCNT(15,True,15*60,True)
#while(1):
# ret, frame = cap.read()
# fgmaskKNN = fgbgKNN.apply(frame)
fgmaskMOG = fgbgMOG.apply(frame)
# fgmaskGMG = fgbgGMG.apply(frame)
# fgmaskMOG2 = fgbgMOG2.apply(frame)
# fgmaskCNT = fgbgCNT.apply(frame)
#
# cv2.imshow('frame',frame)
# cv2.imshow('fgmaskKNN',fgmaskKNN)
cv2.imshow('fgmaskMOG',fgmaskMOG)
# cv2.imshow('fgmaskGMG',fgmaskGMG)
# cv2.imshow('fgmaskMOG2',fgmaskMOG2)
# cv2.imshow('fgmaskCNT',fgmaskCNT)
k = cv2.waitKey(20) & 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
(Below images -> Frame number - 977)
Try also BackgroundSubtractorGSOC and BackgroundSubtractorLSBP
@mshabunin , I tried both of them, In GSOC it has the same problem, it is even more susceptible to light changes. LSBP also has the same problem and it is lagging
How about going a step further and not using BG/FG subtraction but actual object detectors, specificly for cars? You can even combine them with a detection+segmentation approach that will then yield you the outer contour!
@StevenPuttemans But doesn't it slow down the process ? I assume Object Detection (in the entire frame, without first detecting moving object) is too slow to be used in real time. Am I wrong ?
Check these benchmarks: https://github.com/opencv/opencv/wiki...