Ask Your Question

# agroms's profile - activity

 2020-05-26 04:55:37 -0600 received badge ● Notable Question (source) 2018-11-24 22:26:51 -0600 received badge ● Popular Question (source) 2017-05-13 13:00:02 -0600 asked a question Why is contours changing slightly allthough the object is still? Hello, I have been working a lot with contours lately in different video programs. If I measure the contour of a object in realtime or video, and even though the camera and object is not moving at all and nothing is changed in regards to lighting, it seems like the contours are flickering and sometimes changed slightly. It is not more than maybe 1-2 pixel in change along the edge. My question is if there is any special reason for this? Is the program or my computer to slow to calculate exactly the same contour for each frame? Thanks in advance for any explenation! 2017-03-04 14:18:19 -0600 received badge ● Enthusiast 2017-03-02 09:45:03 -0600 commented answer Finding distance between two curves Thanks for the repsonse, I'll try and translate it to Python. But what result does this code give, is it the closest point between the two curves? 2017-02-27 09:08:04 -0600 received badge ● Student (source) 2017-02-23 05:56:45 -0600 commented question Finding distance between two curves How would I implement the cv::distanceTransform? Cant get it to work :/ 2017-02-23 04:38:45 -0600 asked a question Finding distance between two curves Hello, Im trying to add tangents along the curve in the image below, like the red lines in the second picture. Then I would like to use the tangents to find the the 90 degrees normal line to the tangent(the green lines). The goal is to find the distance between the two white lines at different places. I use Python and if anyone have any suggestion on how I could do this, or have any suggestions of a better way, I would be very grateful. (/upfiles/14878459581269807.jpg) 2017-01-24 13:59:27 -0600 commented question Finding distance between two contours in video It works now that I moved the centers=[] inside the while loop. Thanks for the response :) 2017-01-24 06:15:28 -0600 commented question Finding distance between two contours in video Edited to include the entire code. The contour follows the objects for the enitre video, but cant seem to get the values from the contours. 2017-01-24 06:09:51 -0600 received badge ● Editor (source) 2017-01-24 05:15:08 -0600 asked a question Finding distance between two contours in video Hello, Im trying to meassure the distance between two objects using Python. I have managed to do it in a still picture but now Im trying to do it in a video. The program measure the distance D in the first frame of the video, but not continiously as the objects move. Im quite new to Python and openCV, so any help is much appreciated. Here is the code: import numpy as np import cv2 import matplotlib.pyplot as plt cap = cv2.VideoCapture('new4.avi') centers=[] while(True): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) _, thresh = cv2.threshold(gray, 127,255,0) im2, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) for c in contours: if cv2.contourArea(c)<100: continue elif cv2.contourArea(c)>2000: continue cv2.drawContours(frame, [c], -1, (0,255,0), 3) M = cv2.moments(c) cX = int(M['m10'] /M['m00']) cY = int(M['m01'] /M['m00']) centers.append([cX,cY]) if len(centers) >=2: dx= centers[0][0] - centers[1][0] dy = centers[0][1] - centers[1][1] D = np.sqrt(dx*dx+dy*dy) print(D) cv2.imshow('frame', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()  How can I get the value of D to change continiously as the two objects move in the video? *Edit: added the entire code. 2017-01-23 08:21:09 -0600 received badge ● Supporter (source) 2017-01-23 08:12:59 -0600 received badge ● Scholar (source) 2017-01-23 07:42:52 -0600 commented answer How to get first row of np.vstack? midpoint of contour - Python This worked, thank you so much :) 2017-01-23 06:46:49 -0600 asked a question How to get first row of np.vstack? midpoint of contour - Python Hello, Im new to OpenCV and Python, and Im trying to meassure the distance of the midpoints of two contours. This is my code so far: image = cv2.imread('TwoMarkers.jpg') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) ret, thresh = cv2.threshold(gray, 127 , 255, 0) im2, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) for c in contours: # if the contour is not sufficient large, or to small, ignore it if cv2.contourArea(c) > 2000: continue elif cv2.contourArea(c) < 100: continue M = cv2.moments(c) cX = int(M['m10'] /M['m00']) cY = int(M['m01'] /M['m00']) contourMidpoint= np.vstack([(cX, cY)]) D = dist.euclidean(contourMidpoint[0], contourMidpoint[1]) print(D)  How can I get the distance D between the two found values that are stacked? The apporach I tried dident work, and I have no clue how to sepererate the values that are stacked. Any help is much appreciated.