0
$\begingroup$

I am trying to identify the T-rex and obstacles (cactus and bird) from Google's no-internet game.

What I have done is:

  • Apply GaussianBlur filter
  • Apply Canny
  • Apply Dilate
  • Apply erode
  • findContours that returns all external contours, RETR_EXTERNAL

My approach generally works, except that when there is a small bump on the ground next to a cactus, my script will consider the T-rex, the bump on the ground and the cactus as a giant horizontal contour, how do I filter out this horizon? The blue box is the outline of the contour I found.

  • I tried reducing the size of the image I am taking vertically so that the horizon would be left out, but it introduced a different problem: T-rex legs would be cut off and occasionally, T-rex would not be considered as a contour as it is not closed.

enter image description here

When there is no bump on the ground next to a cactus, my script produces the expected result.

enter image description here

$\endgroup$
0
$\begingroup$

I have found a function provided by opencv2, threshold().

With this function, I can apply different combinations of threshold values so that this horizon can be filtered out.

The current values I am using is:

cv2.threshold(img, 100, 255, cv2.THRESH_BINARY)
| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.