0

As title, I tried to use Raspberry Pi + logitech webcam to find the difference between two frames, the following is the code that I used:

import cv2


#capture from camera at location 0
cap = cv2.VideoCapture(0)


while True:
    ret, img = cap.read()
    #cv2.imshow("input", img)

    ...

    framediff = cv2.absdiff(Previousframe, frame)

    ...

    cv2.imshow("frame", framediff)

    key = cv2.waitKey(10)
    if key == 27:
        break


cv2.destroyAllWindows() 
cv2.VideoCapture(0).release()

When there are some moving objects pass through, the webcam will auto change " Focus", "Brightness", "Exposure"...I am not sure... and I will see a lot of noise in framediff, so I think I need to change some setting of my webcam to reduce this kind of noise, I saw someone post about cap.set(), but not sure which setting I need to change, also change to what value... does anyone have this kind of experiences?

migrated from stackoverflow.com Dec 18 '17 at 21:14

This question came from our site for professional and enthusiast programmers.

  • try histogram equalization on each channel – Micka Dec 16 '17 at 17:15
  • Try to use the H-channel after converting BGR2HSV – Jyr Dec 16 '17 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy