SerpentAI / D3DShot

Extremely fast and robust screen capture on Windows with the Desktop Duplication API
MIT License
323 stars 73 forks source link

Inverted Colors #10

Closed rlewkowicz closed 4 years ago

rlewkowicz commented 4 years ago

I can't tell if this is open cv or this library, but one of the channels is messed up

image

vs what it's supposed to look like:

image

I didn't see this issue with other libraries, but I might still be doing something wrong

rlewkowicz commented 4 years ago

OpenCV uses BGR as its default.

frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

Arcitec commented 4 years ago

D3DShot captures RGB images.

OpenCV's functions expect BGR images.

So, as you discovered, the solution is to convert the D3DShot image from RGB -> BGR via cv2.cvtColor.

PS: And btw, cvtColor is the fastest way to do the color conversion. Numpy "magic math" is much slower, as proven here: https://answers.opencv.org/question/219040/fastest-way-to-convert-bgr-rgb-aka-do-not-use-numpy-magic-tricks/