OpenCV

Vectorizing operation on numpy array

纵饮孤独 提交于 2021-02-08 08:13:41
问题 I have a numpy array containing many three-dimensional numpy arrays, where each of these sub-elements is a grayscale image. I want to use numpy's vectorize to apply an affine transformation to each image in the array. Here is a minimal example that reproduces the issue: import cv2 import numpy as np from functools import partial # create four blank images data = np.zeros((4, 1, 96, 96), dtype=np.uint8) M = np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32) # dummy affine transformation matrix

How to obtain the best result from pytesseract?

妖精的绣舞 提交于 2021-02-08 08:08:48
问题 I'm trying to read text from an image, using OpenCV and Pytesseract, but with poor results. The image I'm interested in reading the text is: https://www.lubecreostorepratolapeligna.it/gb/img/logo.png This is the code I am using: pytesseract.pytesseract.tesseract_cmd = r'D:\Program Files\pytesseract\tesseract.exe' image = cv2.imread(path_to_image) # converting image into gray scale image gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('grey image', gray_image) cv2.waitKey(0) #

What does disabling `CV_CAP_PROP_CONVERT_RGB` do?

放肆的年华 提交于 2021-02-08 07:28:37
问题 I'm attempting to get raw camera output with opencv. If I read an image normally I get a 640x480x3 image: >>> import cv2 >>> cap = cv2.VideoCapture(2) >>> _, im = cap.read() >>> im.shape (480, 640, 3) If I disable cv2.CAP_PROP_CONVERT_RGB then I get a strangely sized array, the end of which is always zeros: >>> cap.set(cv2.CAP_PROP_CONVERT_RGB, False) True >>> _, im = cap.read() >>> im.shape (1, 614400) >>> cv2.imshow('im', im.reshape((960, 640))); cv2.waitKey(0) The resulting 'image' is:

What does disabling `CV_CAP_PROP_CONVERT_RGB` do?

依然范特西╮ 提交于 2021-02-08 07:28:36
问题 I'm attempting to get raw camera output with opencv. If I read an image normally I get a 640x480x3 image: >>> import cv2 >>> cap = cv2.VideoCapture(2) >>> _, im = cap.read() >>> im.shape (480, 640, 3) If I disable cv2.CAP_PROP_CONVERT_RGB then I get a strangely sized array, the end of which is always zeros: >>> cap.set(cv2.CAP_PROP_CONVERT_RGB, False) True >>> _, im = cap.read() >>> im.shape (1, 614400) >>> cv2.imshow('im', im.reshape((960, 640))); cv2.waitKey(0) The resulting 'image' is:

What is the most efficient way to capture screen in python using modules eg PIL or cv2? because It takes up a lot of ram

99封情书 提交于 2021-02-08 06:56:23
问题 What is the most efficient way to capture screen in python using modules eg PIL or cv2? Because It takes up a lot of ram. I wanted to teach AI to play dino game of Chrome through screen scraping and neat but it is way to slow... I have tried: import numpy as np from PIL import ImageGrab import cv2 import time last_time = time.time() while True: printscreen_pil = ImageGrab.grab(bbox= (0, 40, 800, 640)) printscreen_numpy = np.array(printscreen_pil.getdata(), dtype = 'uint8').reshape(

Import error while importing cv2 in Spyder(Python 3.6)

[亡魂溺海] 提交于 2021-02-08 06:10:36
问题 I have already installed opencv 3.0.0 in windows os. I have run the application and have successfully installed it in C:\ drive and have also copied the cv2.pyd file in C:\Python27\Lib\site-packages as I saw in several tutorial videos and in my Python 2.7.5 Shell i.e IDLE when I type >>>import cv2 >>> It shows it has been safely installed and running. Now I am using Spyder 3.6 as this is the latest version available for my Machine Learning programs but here if I follow the above steps it

Import error while importing cv2 in Spyder(Python 3.6)

谁说我不能喝 提交于 2021-02-08 06:09:05
问题 I have already installed opencv 3.0.0 in windows os. I have run the application and have successfully installed it in C:\ drive and have also copied the cv2.pyd file in C:\Python27\Lib\site-packages as I saw in several tutorial videos and in my Python 2.7.5 Shell i.e IDLE when I type >>>import cv2 >>> It shows it has been safely installed and running. Now I am using Spyder 3.6 as this is the latest version available for my Machine Learning programs but here if I follow the above steps it

Import error while importing cv2 in Spyder(Python 3.6)

不问归期 提交于 2021-02-08 06:08:32
问题 I have already installed opencv 3.0.0 in windows os. I have run the application and have successfully installed it in C:\ drive and have also copied the cv2.pyd file in C:\Python27\Lib\site-packages as I saw in several tutorial videos and in my Python 2.7.5 Shell i.e IDLE when I type >>>import cv2 >>> It shows it has been safely installed and running. Now I am using Spyder 3.6 as this is the latest version available for my Machine Learning programs but here if I follow the above steps it

Image alpha composite with OpenCV

 ̄綄美尐妖づ 提交于 2021-02-08 05:36:38
问题 I want to implement these steps: Here is my code: import cv2 from skimage.io import * import numpy as np imA = cv2.imread('C.jpg') kernel = np.ones((3, 3), np.uint8) imA = cv2.cvtColor(imA, cv2.COLOR_BGR2GRAY) ret, mask = cv2.threshold(imA, 5, 255, cv2.THRESH_BINARY) opening = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel) imshow(opening) show() imF = cv2.imread('157969651.jpg') imF = cv2.cvtColor(imF, cv2.COLOR_BGR2RGBA) imB = cv2.imread('images.jpg') imB = cv2.cvtColor(imB, cv2.COLOR

Image alpha composite with OpenCV

大憨熊 提交于 2021-02-08 05:36:20
问题 I want to implement these steps: Here is my code: import cv2 from skimage.io import * import numpy as np imA = cv2.imread('C.jpg') kernel = np.ones((3, 3), np.uint8) imA = cv2.cvtColor(imA, cv2.COLOR_BGR2GRAY) ret, mask = cv2.threshold(imA, 5, 255, cv2.THRESH_BINARY) opening = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel) imshow(opening) show() imF = cv2.imread('157969651.jpg') imF = cv2.cvtColor(imF, cv2.COLOR_BGR2RGBA) imB = cv2.imread('images.jpg') imB = cv2.cvtColor(imB, cv2.COLOR