Strange OpenCV Distance Transform Results
By : moin
Date : March 29 2020, 07:55 AM
|
opencv zoom function strange results
By : jack903
Date : March 29 2020, 07:55 AM
Any of those help cv.Resize requires source and destination to be separate memory locations. Now in the first snippet of your code, you are using cv.GetSubRect to generate an object pointing to area of image which you wish to zoom in. Here the new object is NOT pointing to a new memory location. It is pointing to a memory location which is a subset of original object.
|
How to pass a numpy ndarray as a color in OpenCV?
By : Alexander Sadovnikov
Date : March 29 2020, 07:55 AM
wish of those help I am trying to pass a ndarray into this line: cv2.fillPoly(im, pts=[cnt],color=(centroid_color[0],centroid_color[1],centroid_color[2])) , You can pass a numpy array directly as color argument like this: code :
import numpy as np
import cv2
pts = np.array([[[10,40], [70,16], [100,90] ]], np.int32)
im = np.zeros([240,320, 3], np.uint8)
color = np.array((60,0,255))
cv2.fillPoly( im, pts, color)
cv2.imshow(" ", im)
cv2.waitKey(1)
clr = np.array([255, 0, 128])
cv2.fillPoly( im, pts, color=(clr[0], clr[1], clr[2]))
centroid_color = centroid_color.astype(np.int32, copy=False)
|
Opencv python HoughLinesP strange results
By : useryl
Date : March 29 2020, 07:55 AM
this will help NOTE: Since you linked a tutorial for OpenCV 2.4.x, I initially assumed you also wrote your code with OpenCV 2.4.11. As it turns out, you're actually using OpenCV 3.x. Keep in mind that there are subtle changes in the API between 2.x and 3.x. code :
cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) → lines
lines = cv2.HoughLinesP(cannied, rho=1, theta=np.pi / 180
, threshold=80, lines=30, minLineLength=10)
lines = cv2.HoughLinesP(cannied, rho=1, theta=np.pi / 180
, threshold=80, minLineLength=30, maxLineGap=10)
cv2.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) → edges
cannied = cv2.Canny(img, threshold1=50, threshold2=200, edges=3)
cannied = cv2.Canny(img, threshold1=50, threshold2=200, apertureSize=3)
import cv2
import numpy as np
def get_lines(lines_in):
if cv2.__version__ < '3.0':
return lines_in[0]
return [l[0] for l in lines]
img = cv2.imread('building.jpg')
img_gray = gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cannied = cv2.Canny(img_gray, threshold1=50, threshold2=200, apertureSize=3)
lines = cv2.HoughLinesP(cannied, rho=1, theta=np.pi / 180, threshold=80, minLineLength=30, maxLineGap=10)
for line in get_lines(lines):
leftx, boty, rightx, topy = line
cv2.line(img, (leftx, boty), (rightx,topy), (255, 255, 0), 2)
cv2.imwrite('lines.png',img)
cv2.imwrite('canniedHouse.png',cannied)
cv2.waitKey(0)
cv2.destroyAllWindows()
|
OpenCV BackgroundSubtractor yields poor results on objects with similar color as background color
By : Daniel Hanley
Date : March 29 2020, 07:55 AM
Any of those help I believe following the steps below will solve your first problem to a large extent: 1.Preprocessing:
|