tag:blogger.com,1999:blog-4813964839877266385.post7816609413576299418..comments2022-04-02T04:40:26.895-07:00Comments on txyz.info: Liquid level processing with OpenCV & Pythontxyz.infohttp://www.blogger.com/profile/14846362857116832543noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4813964839877266385.post-65665045522463689222019-07-09T06:21:22.888-07:002019-07-09T06:21:22.888-07:00This code fixes the crashes:
import cv2
import ma...This code fixes the crashes:<br /><br />import cv2<br />import math<br /><br />cap = cv2.VideoCapture(0)<br />cap.set(3, 640)<br />cap.set(4, 480)<br /><br />while True:<br /> ret, img = cap.read()<br /> if img is None:<br /> break<br /> gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br /> edges = cv2.Canny(gray, 100, 120)<br /> lines = cv2.HoughLinesP(edges, 1, math.pi / 1, 20, None, 2, 480)<br /><br /> if lines is None:<br /> print('No Hough Lines found in image.')<br /> break<br /> else:<br /> dot1 = (lines[0][0][0], lines[0][0][1])<br /> dot2 = (lines[0][0][2], lines[0][0][3])<br /> cv2.line(img, dot1, dot2, (255, 0, 0), 3)<br /> cv2.imshow("output", img)<br /> length = lines[0][0][1] - lines[0][0][3]<br /> print(length)<br /> key = cv2.waitKey(10)<br /> if key == 27:<br /> break<br /><br />cap.release()<br />cv2.destroyAllWindows()<br />Jeremy Demershttps://www.blogger.com/profile/11430469315381019543noreply@blogger.comtag:blogger.com,1999:blog-4813964839877266385.post-78574373672103970852019-07-09T06:14:34.964-07:002019-07-09T06:14:34.964-07:00This comment has been removed by the author.Jeremy Demershttps://www.blogger.com/profile/11430469315381019543noreply@blogger.comtag:blogger.com,1999:blog-4813964839877266385.post-84671994372687201702019-05-11T00:51:03.580-07:002019-05-11T00:51:03.580-07:00Thats bcoz it didnt detect any lines in the image/...Thats bcoz it didnt detect any lines in the image/frameSreeramhttps://www.blogger.com/profile/00981788715941928107noreply@blogger.comtag:blogger.com,1999:blog-4813964839877266385.post-50295889422637439702016-12-28T06:42:41.837-08:002016-12-28T06:42:41.837-08:00Hi, thanks for the code.But I'm getting an err...Hi, thanks for the code.But I'm getting an error, please help me with it.<br /><br />Traceback (most recent call last):<br /> File "C:/Users/Hari/Downloads/New folder/liquid.py", <br /> line 17, in <br /> dot1 = (lines[0][0][0],lines[0][0][1])<br /> TypeError: 'NoneType' object is not subscriptable<br /><br />Hari kishore K Ahttps://www.blogger.com/profile/04693978629751405110noreply@blogger.com