cv2

How do I install opencv using pip?

人走茶凉 提交于 2019-11-30 14:31:03
问题 I need to install cv2 for a script that has been written for me. I tried pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python . So, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff. What do I do now? 回答1: Install opencv-python (which is an unofficial pre-built

How to merge lines after HoughLinesP?

落花浮王杯 提交于 2019-11-29 09:53:41
问题 My task is to find coordinates of lines (startX, startY, endX, endY) and rectangles (4 lines). Here is input file: I use the next code: img = cv2.imread(image_src) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret, thresh1 = cv2.threshold(gray,127,255,cv2.THRESH_BINARY) edges = cv2.Canny(thresh1,50,150,apertureSize = 3) minLineLength = 100 maxLineGap = 10 lines = cv2.HoughLinesP(edges,1,np.pi/180,10,minLineLength,maxLineGap) print(len(lines)) for line in lines: cv2.line(img,(line[0][0],line[0]

“DLL load failed” when import cv2 (opencv)

会有一股神秘感。 提交于 2019-11-29 08:11:37
问题 I spent many hours to solve this problem but I can't find a solution, please any clue that you know to share with me. in [windows server 2012 R2 x64, python 3.7 64x] pip install opencv-contrib-python installed without any error . and when I try to import it import cv2 show me this error : Traceback (most recent call last): File "test.py", line 1, in <module> import cv2 File "C:\Program Files\Python37\lib\site-packages\cv2\__init__.py", line 3, in <module> from .cv2 import * ImportError: DLL

Removing horizontal underlines

大兔子大兔子 提交于 2019-11-28 04:33:33
I am attempting to pull text from a few hundred JPGs that contain information on capital punishment records; the JPGs are hosted by the Texas Department of Criminal Justice (TDCJ). Below is an example snippet with personally identifiable information removed. I've identified the underlines as being the impediment to proper OCR --if I go in, screenshot a sub-snippet and manually white-out lines, the resulting OCR through pytesseract is very good. But with underlines present, it's extremely poor. How can I best remove these horizontal lines? What I have tried: Started on OpenCV doc's walkthrough:

Removing horizontal underlines

余生颓废 提交于 2019-11-27 00:30:37
问题 I am attempting to pull text from a few hundred JPGs that contain information on capital punishment records; the JPGs are hosted by the Texas Department of Criminal Justice (TDCJ). Below is an example snippet with personally identifiable information removed. I've identified the underlines as being the impediment to proper OCR --if I go in, screenshot a sub-snippet and manually white-out lines, the resulting OCR through pytesseract is very good. But with underlines present, it's extremely poor

Open Cv Error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

跟風遠走 提交于 2019-11-26 23:19:53
Currently using Windows 10 with Python 3.7 I tried running with this code in order to get the webcam to function for use in number recognition def get_img_contour_thresh(img): x, y, w, h = 0, 0, 300, 300 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(gray, (5, 5), 0) ret, thresh1 = cv2.threshold(blur, 175, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) thresh1 = thresh1[y:y + h, x:x + w] contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)[-2:] return img, contours, thresh1 def show_webcam(mirror=False): # load json and create model json

Open Cv Error: (-215:Assertion failed) !_src.empty() in function &#39;cv::cvtColor&#39;

十年热恋 提交于 2019-11-26 08:38:07
问题 Currently using Windows 10 with Python 3.7 I tried running with this code in order to get the webcam to function for use in number recognition def get_img_contour_thresh(img): x, y, w, h = 0, 0, 300, 300 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(gray, (5, 5), 0) ret, thresh1 = cv2.threshold(blur, 175, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) thresh1 = thresh1[y:y + h, x:x + w] contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX

DLL load failed error when importing cv2

微笑、不失礼 提交于 2019-11-26 04:46:50
问题 I have installed opencv on my windows machine using python 3.6 without any issues, using: pip install opencv-python but when I try to import cv2 I get the following error ImportError: DLL load failed: The specified module could not be found. I have seen this post It says cv2 doesn\'t work with python 3 I was wondering if this has been fixed or if there is a way around it 回答1: You can download the latest OpenCV 3.2.0 for Python 3.6 on Windows 32-bit or 64-bit machine, look for file starts with