Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

python openCV is detecting colors other then what i am looking for

$
0
0

I am trying to make a python bot for a roblox game where you hit spacebar whenever a white bar hovers over a yellow bar. However I am having a problem detecting the right color pixels. Whenever I try to check for pixels with a RGB value of 255,255,0 it gets colors other then yellow like light green and white.

import randomimport cv2import keyboardimport numpy as npgame_img = cv2.imread('test.png', cv2.IMREAD_UNCHANGED)dodge_img = cv2.imread('dodge8.png', cv2.IMREAD_UNCHANGED)print(type(game_img))print(game_img.shape)for y in range(0,game_img.shape[0]):    for x in range(0,game_img.shape[1]):        if np.any(game_img[y][x] == [255,255,0]):            game_img[y][x] = [random.randint(0,255),random.randint(0,255),random.randint(0,255)]cv2.imshow("this", game_img)cv2.waitKey(0)

Original Image:

Original Image

Image After "yellow" pixels were changed:

Image After "yellow" pixels were changed


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>