elerac / EasyPySpin

cv2.VideoCapture like wrapper for FLIR Spinnaker SDK
MIT License
99 stars 19 forks source link

The image has spots #4

Closed Circle-Kai closed 3 years ago

Circle-Kai commented 3 years ago

Thank you for providing this package. The images saved in the SDK are normal, but spots appear when using EasyPySpin. What parameters can I adjust to improve this problem?

You can see some spots above the image.

elerac commented 3 years ago

Hi, @Circle-Kai !

Your camera has RGB color sensor, right? The spots you are talking about is probably caused by the color filter array. EasyPySpin returns the bayer pattern image (like the second one). So, you need to do demosaicing after capturing the image. Try the code below.

import cv2
import EasyPySpin

cap = EasyPySpin.VideoCapture(0)
ret, frame = cap.read()

frame_bgr = cv2.demosaicing(frame, cv2.COLOR_BayerBG2BGR) # The second argument may need to be changed depending on your sensor.

cv2.imwrite("frame_bgr.png", frame_bgr)
Circle-Kai commented 3 years ago

Because I want to get grayscale images, I use image. Convert() to convert images . I added this code before GetNDArray().

image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)

https://github.com/elerac/EasyPySpin/blob/76192a93fa1b4b2b1b0ffb451d7e466e3341a397/EasyPySpin/videocapture.py#L135

If there is an error, please tell me again, thanks

elerac commented 3 years ago

Did you solve it? That sounds like a good idea too. I'm glad if you solved it.

Circle-Kai commented 3 years ago

Yes, it has been resolved. Thank you.