computer-vision

taking images from webcam

穿精又带淫゛_ 提交于 2021-02-11 04:54:55
问题 I have this script to capture images from webcam, but it is not saving any image, I donot know why. I am getting this error " Traceback (most recent call last): File "C:/Users/Iram/.PyCharmCE2019.3/config/scratches/scratch_5.py", line 26, in gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' [ WARN:0] global C:\projects\opencv-python

taking images from webcam

一个人想着一个人 提交于 2021-02-11 04:54:17
问题 I have this script to capture images from webcam, but it is not saving any image, I donot know why. I am getting this error " Traceback (most recent call last): File "C:/Users/Iram/.PyCharmCE2019.3/config/scratches/scratch_5.py", line 26, in gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' [ WARN:0] global C:\projects\opencv-python

how to import multiple layers from tif file with opencv

試著忘記壹切 提交于 2021-02-10 16:54:14
问题 I'm using python (cv2) to import a .tif file with three layers, but I only seem to be able to import one layer. How can i separately import all three layers? import cv2 img = cv2.imread('LanB2_KD1P2_31603_gut_2.tif', cv2.IMREAD_COLOR) #extract blue channel blue_channel = img[:,:,0] #write blue channel to greyscale image cv2.imwrite('blue_channel.jpg',blue_channel) this extracts the blue channel from the first layer but idk how to get the other layers 回答1: You can simply use cv2.split for

rotation angle of the perspective matrix

China☆狼群 提交于 2021-02-10 15:49:21
问题 How can I detect the rotation angle from a perspective matrix? I wrote this code ,but the resulted angle doesn't exceed 40 ... Mat mmat; mmat.create(3,3,CV_32FC1); mmat=getPerspectiveTransform(templPoints,imgPoints); cout<< mmat<<endl<<endl; float angle=acos(mmat.at<double>(0,0)); angle=(angle*180)/3.14; cout<<"angle is"<<angle<<endl; 回答1: getPerspectiveTransform returns an homography matrix which can be decomposed like this: [R11,R12,T1] [R21,R22,T2] [ P , P , 1] R represents a rotation

Corner detection algorithm gives very high value for slanted edges?

故事扮演 提交于 2021-02-10 07:44:51
问题 I have tried implementing a basic version of shi-tomasi corner detection algorithm. The algorithm works fine for corners but I came across a strange issue that the algorithm also gives high values for slanted(titled) edges. Here's what i did Took gray scale image computer dx, and dy of the image by convolving it with sobel_x and sobel_y Took a 3 size window and moved it across the image to compute the sum of the elements in the window. computed sum of the window elements from the dy image and

How to remove all portrait pictures from a document

风格不统一 提交于 2021-02-10 06:47:14
问题 I am working on OCRing a document image. I want to detect all pictures and remove from the document image. I want to retain tables in the document image. Once I detect pictures I will remove and then want to OCR. I tried to find contour tried to detect all the bigger areas. unfortunately it detects tables also. Also how to remove the objects keeping other data in the doc image. I am using opencv and python Here's my code import os from PIL import Image import pytesseract img = cv2.imread(

How to repair incomplete grid cells and fix missing sections in image

孤人 提交于 2021-02-10 05:59:11
问题 I used Hough lines to get intersection of horizontal and vertical lines in this image: but the complexity grows with the grid cells count significantly. Is there any simple way to complete the grid without using line detection ? Thank you. 回答1: Here's a potential solution using morphological operations with OpenCV Obtain binary image. Load image, grayscale, Gaussian blur, Otsu's threshold Obtain horizontal/vertical lines masks. Create horizontal/vertical kernel and isolate horizontal/vertical

How to repair incomplete grid cells and fix missing sections in image

怎甘沉沦 提交于 2021-02-10 05:56:49
问题 I used Hough lines to get intersection of horizontal and vertical lines in this image: but the complexity grows with the grid cells count significantly. Is there any simple way to complete the grid without using line detection ? Thank you. 回答1: Here's a potential solution using morphological operations with OpenCV Obtain binary image. Load image, grayscale, Gaussian blur, Otsu's threshold Obtain horizontal/vertical lines masks. Create horizontal/vertical kernel and isolate horizontal/vertical

Convert gray image to colored image using feature extraction method in ML

江枫思渺然 提交于 2021-02-10 05:33:07
问题 I have a feature array which is created from ORB with this code part: orb = cv2.ORB_create() #keypoints and descriptors kpO, desO = orb.detectAndCompute(gray_image, None) I create this gray image from colored one. And des0.shape is (500,32). Also shape of my original image(colored one) is (422, 750, 3). And I want to decisionTreeRegression from these arrays for predict the colored version of grayscale image which is I created from colored version. But the problem is starting here , feature

Upsampling in Semantic Segmentation

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-09 11:14:29
问题 I am trying to implement a paper on Semantic Segmentation and I am confused about how to Upsample the prediction map produced by my segmentation network to match the input image size. For example, I am using a variant of Resnet101 as the segmentation network (as used by the paper). With this network structure, an input of size 321x321 (again used in the paper) produces a final prediction map of size 41x41xC (C is the number of classes). Because I have to make pixel-level predictions, I need