Ask Your Question

Revision history [back]

way to find Zebra crossing lines

import cv2 import numpy as np image = cv2.imread('abbey_road.jpg',-1) paper = cv2.resize(image,(500,500)) ret, thresh_gray = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY), 200, 255, cv2.THRESH_BINARY) contours, hier = cv2.findContours(thresh_gray, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE) for c in contours: print(c) rect = cv2.minAreaRect(c) box = cv2.boxPoints(rect) # convert all coordinates floating point values to int box = np.int0(box) # draw a green 'nghien' rectangle cv2.drawContours(paper, [box], 0, (0, 255, 0),1)

cv2.imshow('paper', paper)

cv2.imwrite('paper.jpg',paper) cv2.waitKey(0)image description

I tried the above code for zebra detection,but it end up with detecting all thewhite boxes but not the whole are.Is there any way to solve this?

click to hide/show revision 2
None

updated 2020-02-14 02:39:59 -0600

berak gravatar image

way to find Zebra crossing lines

.

import cv2
import numpy as np
image = cv2.imread('abbey_road.jpg',-1)
paper = cv2.resize(image,(500,500))
ret, thresh_gray = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY),
                        200, 255, cv2.THRESH_BINARY)
contours, hier = cv2.findContours(thresh_gray, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
for c in contours:
    print(c)
    rect = cv2.minAreaRect(c)
    box = cv2.boxPoints(rect)
    # convert all coordinates floating point values to int
    box = np.int0(box)
    # draw a green 'nghien' rectangle
    cv2.drawContours(paper, [box], 0, (0, 255, 0),1)

0),1) cv2.imshow('paper', paper)

cv2.imshow('paper', paper)

cv2.imwrite('paper.jpg',paper) cv2.waitKey(0)image description

cv2.waitKey(0)![image description](/upfiles/1581660638287198.jpg)

I tried the above code for zebra detection,but it end up with detecting all thewhite boxes but not the whole are.Is there any way to solve this?

way to find Zebra crossing lines

.

import cv2
import numpy as np
image = cv2.imread('abbey_road.jpg',-1)
paper = cv2.resize(image,(500,500))
ret, thresh_gray = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY),
                        200, 255, cv2.THRESH_BINARY)
contours, hier = cv2.findContours(thresh_gray,  cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
for c in contours:
    print(c)
    rect = cv2.minAreaRect(c)
    box = cv2.boxPoints(rect)
    # convert all coordinates floating point values to int
    box = np.int0(box)
    # draw a green 'nghien' rectangle
    cv2.drawContours(paper, [box], 0, (0, 255, 0),1)
0),1)

cv2.imshow('paper', paper) paper)

cv2.imwrite('paper.jpg',paper) cv2.waitKey(0)![image description](/upfiles/1581660638287198.jpg)

cv2.waitKey(0)

image description

I tried the above code for zebra detection,but it end up with detecting all thewhite boxes but not the whole are.Is there any way to solve this?

way to find Zebra crossing lines

import cv2 import numpy as np image = cv2.imread('abbey_road.jpg',-1) paper = cv2.resize(image,(500,500)) ret, thresh_gray = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY), 200, 255, cv2.THRESH_BINARY) contours, hier = cv2.findContours(thresh_gray, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE) for c in contours: print(c) rect = cv2.minAreaRect(c) box = cv2.boxPoints(rect) # convert all coordinates floating point values to int box = np.int0(box) # draw a green 'nghien' rectangle cv2.drawContours(paper, [box], 0, (0, 255, 0),1)

cv2.imshow('paper', paper)

paper) cv2.imwrite('paper.jpg',paper) cv2.waitKey(0)

cv2.waitKey(0)

image description

I tried the above code for zebra detection,but it end up with detecting all thewhite boxes but not the whole are.Is there any way to solve this?

way to find Zebra crossing lines

Code:

import cv2
 import numpy as np
 image = cv2.imread('abbey_road.jpg',-1)
 paper = cv2.resize(image,(500,500))
 ret, thresh_gray = cv2.threshold(cv2.cvtColor(paper, cv2.COLOR_BGR2GRAY),
                         200, 255, cv2.THRESH_BINARY)
 contours, hier = cv2.findContours(thresh_gray,  cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
 for c in contours:
     print(c)
     rect = cv2.minAreaRect(c)
     box = cv2.boxPoints(rect)
     # convert all coordinates floating point values to int
     box = np.int0(box)
     # draw a green 'nghien' rectangle
     cv2.drawContours(paper, [box], 0, (0, 255, 0),1)

0),1)
cv2.imshow('paper', paper)

cv2.imwrite('paper.jpg',paper)
cv2.waitKey(0)

image description

I tried the above code for zebra detection,but it end up with detecting all thewhite boxes but not the whole are.Is there any way to solve this?