opencv3.0

Python multiprocessing - How can I split workload to get speed improvement?

泪湿孤枕 提交于 2019-12-01 10:52:48
I am writing a simple code of cropping images and saving it. But the problem is that the number of images is about 150,000+ and I want to improve the speed. So, at first I wrote a code with simple for loops, like the following: import cv2 import numpy import sys textfile=sys.argv[1] file_list=open(textfile) files=file_list.read().split('\n') idx=0 for eachfile in files: image=cv2.imread(eachfile) idx+=1 if image is None: pass outName=eachfile.replace('/data','/changed_data') if image.shape[0]==256: image1=image[120:170,120:170] elif image.shape[0]==50: image1=image cv2.imwrite(outName,image1)

OpenCV 3.0 VideoCapture doesn't open video file in Java

做~自己de王妃 提交于 2019-12-01 08:20:59
问题 OpenCV 3.0 with Java cannot open video file, but it woks with camera. Before I was using OpenCV 3.0-beta it was working well in both, but in OpenCV 3.0 which is released on 2015-04-24 doesn't work with video file. If anyone know about this problem of OpenCV 3, please tell me the reason and how to solve this. 回答1: I solved my problem like this: Copy the C:\opencv\build\x64\vc12\bin to the system path and restart the Eclipse. Hope this help someone that may has this problem with OpenCV 3.0. 回答2

HSL range for yellow lane lines

孤街浪徒 提交于 2019-12-01 07:30:54
问题 I am currently working on simple lane detection and I have some trouble finding the range/input values for yellow colored lane lines. def color_filter(image): #convert to HLS to mask based on HLS hls = cv2.cvtColor(image, cv2.COLOR_BGR2HLS) lower = np.array([0,190,0]) upper = np.array([255,255,255]) yellower = np.array([40,70,60]) #NOT SURE WHAT TO PUT yelupper = np.array([50,90,65]) #NOT SURE WHAT TO PUT yellowmask = cv2.inRange(hls, yellower, yelupper) whitemask = cv2.inRange(hls, lower,

ImportError: dynamic module does not define module export function (PyInit_cv2)

佐手、 提交于 2019-12-01 06:37:04
When I try to import cv2 in IPython , I am getting this error- ImportError: dynamic module does not define module export function (PyInit_cv2) I have opencv 3.0, ubuntu 14.04, python 3.4. I searched online but couldn't get any answer. Julian Python3 libraries usually can be found in: /usr/lib/python3/dist-packages I found out that the library cv2.cpython-34m.so is needed for Python3.4. But this file wasn't be contained in my default library directory. In my environment, this library was stored in /usr/ local /lib/python3.4/dist-packages/ So I created a symbolic link. Try it with: cd /usr/lib

Speed up live plotting of a footage (cv2)

冷暖自知 提交于 2019-12-01 01:21:27
I am attempting to use the cv2 module to create a live scatter plot for each frame of a video. The code below does exactly that. However with more than 8 minute of footage containing more than 60000 frames to process, the code is not efficient and does take much longer than necessary to get the desired output. vidcap = cv2.VideoCapture(filepath) fig, ax = plt.subplots(1) plt.ion() x=df["time"][7:100] y=df["force"][7:100] for i in range(len(x)): vidcap.set(1,590) ret, image = vidcap.read() frameId = vidcap.get(1) plt.imshow(image,extent=[0,200,0,100], aspect='auto') plt.subplot(221) plt.plot(x

Using OpenCL accelerated functions with OpenCV3 in Python

人盡茶涼 提交于 2019-11-30 14:26:05
OpenCV3 introduced its T-API (Transparent API) which gives the user the possibility to use functions which are GPU (or other OpenCL enabled device) accelerated, I'm struggling to find how to tap into that with Python. With C++ there are calls like ocl::setUseOpenCL(true); that enable OpenCL acceleration when you use UMat instead of Mat objects. However I found no documentation whatsoever for Python. Does anybody have any sample code, links or guides on how to achieve OpenCL acceleration with OpenCV3 in Python? UPDATE: After some further digging I've found this in modules/core/include/opencv2

Python opencv sorting contours

你说的曾经没有我的故事 提交于 2019-11-30 12:04:47
问题 I am following this question: How can I sort contours from left to right and top to bottom? to sort contours from left-to-right and top-to-bottom. However, my contours are found using this (OpenCV 3): im2, contours, hierarchy = cv2.findContours(threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) and they are formatted like this: array([[[ 1, 1]], [[ 1, 36]], [[63, 36]], [[64, 35]], [[88, 35]], [[89, 34]], [[94, 34]], [[94, 1]]], dtype=int32)] When I run the code max_width = max(contours, key

OpenCV for OCR: How to compute thresholding levels for gray image OCR

孤街浪徒 提交于 2019-11-30 10:32:15
I'm trying to prepare images for OCR, and so far here is what I've done using info from Extracting text OpenCV From the resulting image I use the contours that have been filtered to make a mask as follow: //this is the mask of all the text Mat maskF = Mat::zeros(rgb.rows, rgb.cols, CV_8UC1); // CV_FILLED fills the connected components found - CV_FILLED to fill drawContours(maskF, letters, -1, Scalar(255), CV_FILLED); cv::imwrite("noise2-Mask.png", maskF); the resulting img is promising: considering this was my original img: Unfortunately running Tesseract on it yields some issues, I think the

input arguments of python's cv2.calibrateCamera

北慕城南 提交于 2019-11-30 10:27:58
I get the following error when I try to calibrate camera using cv2.calibrateCamera: rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(pts3d, pts2d, self.imgsize, None, None) cv2.error: /home/sarkar/opencv/opencv/modules/calib3d/src/calibration.cpp:2976: error: (-210) objectPoints should contain vector of vectors of points of type Point3f in function collectCalibrationData I initially had nx3 and nx2 array for pts3d and pts2d. I then tried to reshape pts3d and pts2d in the following form as the function takes vectors of vector point3d (and correspondingly pts2d) as input: [1 x

Color Correction Matrix in LAB Color Space - OpenCV

六月ゝ 毕业季﹏ 提交于 2019-11-30 05:39:44
问题 Suppose we have l,a,b values for 5 circles inside an image. These values are calculated using OpenCV. imlab=cv2.cvtColor(circle_img_only,cv2.COLOR_BGR2LAB).astype("float32") Actually, we take 100 random pixels from every circle and calculate normal average LAB value for every circle (Which I am not sure it is the right way to do) values are np.array similar to the following: LAB Measured Colors Values = [[ 27.553 -26.39 7.13 ] [ 28.357 -27.08 7.36 ] [ 28.365 -27.01 7.21 ] [ 29.749 -27.78 7.42