cv2

Error while resizing image: “error: (-215:Assertion failed) func != 0 in function 'resize'”

我们两清 提交于 2020-05-14 18:11:27
问题 I'm trying to preprocess images dataset, represented in numpy array with images of shape (28, 28) by rescaling them to (10, 10). I wrote a function for that: def resize_dataset(images): resized_images = [] for img in images: img = img.reshape((28,28)) resized_img = cv2.resize(img, dsize=(10, 10)) resized_images.append(resized_img) return numpy.array(resized_images) But when I actually try to rescale them, I get the following error in cv2.resize : error: OpenCV(4.0.0) /io/opencv/modules

Error while resizing image: “error: (-215:Assertion failed) func != 0 in function 'resize'”

◇◆丶佛笑我妖孽 提交于 2020-05-14 18:11:05
问题 I'm trying to preprocess images dataset, represented in numpy array with images of shape (28, 28) by rescaling them to (10, 10). I wrote a function for that: def resize_dataset(images): resized_images = [] for img in images: img = img.reshape((28,28)) resized_img = cv2.resize(img, dsize=(10, 10)) resized_images.append(resized_img) return numpy.array(resized_images) But when I actually try to rescale them, I get the following error in cv2.resize : error: OpenCV(4.0.0) /io/opencv/modules

ImportError: No module named 'cv2' Python3

非 Y 不嫁゛ 提交于 2020-05-07 12:47:12
问题 I have such a problem (face_det) user@pc:~$ python3 Python 3.5.3 (default, Apr 22 2017, 00:00:00) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'cv2 I don't have it on python2: (face_det) user@pc:~$ python2 Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2 Type

Python cv2 & numpy - combining two images

烈酒焚心 提交于 2020-04-30 04:32:07
问题 I have an image of a boat and I need to fulfill with colour individual zones according to the value of the sensor. Up to this moment I have created two separated zones in .png format and I want to show them at the same time, putting them on a basic boat image. My code: import cv2 import numpy as np from PIL import Image import time bg = cv2.imread("boat.png") #RGB = np.zeros((2178, 2904, 3), dtype=np.uint8) #zone11 zone11 = cv2.imread(r'C:\Users\Lenovo\Anaconda3\Programy\Obszary\11.png')

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

穿精又带淫゛_ 提交于 2020-04-06 08:49:15
问题 I am trying to recognize text from an image to then have the text outputted; however, this error spits out: Traceback (most recent call last): File "C:/Users/Benji's Beast/AppData/Local/Programs/Python/Python37-32/imageDet.py", line 41, in print(get_string(src_path + "cont.jpg") ) File "C:/Users/Benji's Beast/AppData/Local/Programs/Python/Python37-32/imageDet.py", line 15, in get_string img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(3.4.4) C:\projects\opencv-python\opencv

Extracting selected text by bounding box from an image

不羁岁月 提交于 2020-02-29 03:55:08
问题 I am trying to fetch selected text by bounding box on an Image. like if only on word is selected by bounding box and I want to fetch that text and convert it into the text file. Please see my code and give some review so I can implement that functionality. So far what I've done I've converted the PDF file to image with bounding box over the text. import numpy as np import csv import io from PIL import Image import pytesseract from wand.image import Image as wi from pytesseract import Output

How to draw Chinese text on the image using `cv2.putText`correctly? (Python+OpenCV)

人盡茶涼 提交于 2020-02-27 19:10:49
问题 I use python cv2(window10, python2.7) to write text in image, when the text is English it works, but when I use Chinese text it write messy code in the image. Below is my code: # coding=utf-8 import cv2 import numpy as np text = "Hello world" # just work # text = "内容理解团队" # messy text in the image cv2.putText(img, text, cord, font, fontScale, fontColor, lineType) # Display the image cv2.imshow("img", img) cv2.waitKey(0) cv2.destroyAllWindows() When text = "Hello world" # just work , below is

python how to save videos by different names?

自古美人都是妖i 提交于 2020-01-25 10:13:09
问题 My aim is recording stream and saving that stream into folders. The problem is, I have to save every 5 seconds long of stream into different folders. I mean for a 30 seconds long stream, there should be 6 folders. My code is working but I can't measure the seconds correctly, I divided the frames (a) into fps. But it did not give the correct result. Also I cannot save videos into different folders by using different names. I have to give different names but I don't know how to do it. import

python how to save videos by different names?

对着背影说爱祢 提交于 2020-01-25 10:13:06
问题 My aim is recording stream and saving that stream into folders. The problem is, I have to save every 5 seconds long of stream into different folders. I mean for a 30 seconds long stream, there should be 6 folders. My code is working but I can't measure the seconds correctly, I divided the frames (a) into fps. But it did not give the correct result. Also I cannot save videos into different folders by using different names. I have to give different names but I don't know how to do it. import

Python 2.7/OpenCV 3.3: Error in cv2.initUndistortRectifyMap . Not showing undistort rectified images

耗尽温柔 提交于 2020-01-13 19:55:47
问题 I want to distort and rectified my stereo images. For which I used Opencv 3.3 in Python 2.7. Code I used is : import cv2 import numpy as np cameraMatrixL = np.load('mtx_left.npy') distCoeffsL = np.load('dist_left.npy') cameraMatrixR = np.load('mtx_right.npy') distCoeffsR = np.load('dist_right.npy') R = np.load('R.npy') T = np.load('T.npy') imgleft = cv2.imread('D:\python\camera calibration and 3d const\left\left60.png',0) imgright = cv2.imread('D:\python\camera calibration and 3d const\Right