OpenCV

How to calculate Angle of a square object with respect to image in 2D plane using camera?

喜你入骨 提交于 2021-01-29 07:46:37
问题 I have captured an image using a webcam, attached upside-down above a table horizontally. On the table, I have a square object or piece of card. I have successfully detected the object and found its center coordinates (centroid). Now I want to find the rotation angle of the object with respect to the image. Considering everything in the 2D image plane. How can I calculate the angle? This image represents what I trying to achieve: 回答1: I got the Solution . I write the code to perform the

imshow resize + count white pixels

旧城冷巷雨未停 提交于 2021-01-29 07:18:53
问题 This is a simple program to read video files from your computer. My original video is 1080p resolution. When I run the code, the program's screen (imshow) exceeds my pc's screen which is only 720p. How to resize it from 1080p to 720 or 480p. Second question, how to find the number of pixels in the screen? My code: import numpy as np import cv2 cap = cv2.VideoCapture('apple.mp4') while(cap.isOpened()): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame'

THREE.CanvasTexture needsUpdate no helps

可紊 提交于 2021-01-29 07:17:04
问题 I have video tag and he plays simple video. [works] I have canvas2d with playing same video [works] opencvjs video processing (canvas is output , video is input)- also works I have three.js with plane mesh texture = new THREE.CanvasTexture(this.$refs.testcanvas) texture.needsUpdate = true; materialLocal = new THREE.MeshBasicMaterial({ map: texture }) materialLocal.needsUpdate = true; materialLocal.map.needsUpdate = true; this.mainVideoMesh.material = materialLocal this.mainVideoMesh.material

Catch print output

久未见 提交于 2021-01-29 07:15:59
问题 I’m using opencv and there is a call for video frame reading with VideoCapture and there is print statement automatically printing errors and information on console , and I want to catch these outputs and save to a file .. VideoCapture is not returning this statements it’s just directly printing How do I do that ? 回答1: I dont know if its the best way to do this but it will work. You can read in everything your program prints into the console by typing this: Here we print print("test-test-test

how to find the template matching accuracy

别来无恙 提交于 2021-01-29 06:55:50
问题 i am doing a template matching now,what i want to do is find the accuracy of template matching I have done template matching, but how do i get the accuracy i think i have to subtract the matched region and template image. how do i achieve this CODE import cv2 as cv import numpy as np import matplotlib.pyplot as plt img = cv.imread('image.jpg',0) img1 = img.copy() template = cv.imread('template.jpg',0) w, h = template.shape[::-1] method = ['cv.TM_CCOEFF_NORMED','cv.TM_CCORR_NORMED'] for meth

How To Get The Pixel Count Of A Segmented Area in an Image I used Vgg16 for Segmentation

人盡茶涼 提交于 2021-01-29 06:44:59
问题 I am new to deep learning but have succeeded in semantic segmentation of the image I am trying to get the pixel count of each class in the label. As an example in the image I want to get the pixel count of the carpet, or the chandelier or the light stand. How do I go about? Thanks any suggestions will help. 回答1: Edit: In what format the regions are returned? Do you have only the final image or the regions are given as contours? If you have them as contours (list of coordinates), you can apply

RGB to HSV in numpy

偶尔善良 提交于 2021-01-29 06:44:51
问题 I'm trying to implement RGB to HSV conversion from opencv in pure numpy using formula from here: def rgb2hsv_opencv(img_rgb): img_hsv = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2HSV) return img_hsv def rgb2hsv_np(img_rgb): assert img_rgb.dtype == np.float32 height, width, c = img_rgb.shape r, g, b = img_rgb[:,:,0], img_rgb[:,:,1], img_rgb[:,:,2] t = np.min(img_rgb, axis=-1) v = np.max(img_rgb, axis=-1) s = (v - t) / (v + 1e-6) s[v==0] = 0 # v==r hr = 60 * (g - b) / (v - t + 1e-6) # v==g hg = 120 +

Calculating Percentage of Image Overlap

故事扮演 提交于 2021-01-29 06:42:35
问题 I’m currently working on an image registration algorithm which uses aerial imagery. My objective is to compute the percentage of overlap between two images as shown below. Visually the images have about 50% overlap, I'm using OpenCV following this implementation and this formula, the registered images are warped making it's implementation tricky. A similar implementation with a different formula can be found here. Are there any simpler workarounds to just find a rough estimate of the overlap?

Using distortion co-efficients on a distorted image to un-distort

不想你离开。 提交于 2021-01-29 05:44:36
问题 Given the distortion co-efficients D = k1,k2,p1,p2,k3 of a pinhole model which is defined by radial and tangential distortion. How to undistort an image with these co-efficients? I know about the cv2.undistort() function. Can anyone explain me how to implement the undistortion function to perform iterative minimization? # TODO: Iterative minimization required r2 = x_ * x_ + y_ * y_ # Remove tangential distortion x_tangential = x_ - (2 * distort_coeffs[2] * x_ * y_ + distort_coeffs[3] * (r2 +

video capture card (webcam like) with OpenCV

末鹿安然 提交于 2021-01-29 05:31:10
问题 I want to use video capture card to capture my screen display, and process the image by OpenCV/C++. I have heard that there's some video capture card which is webcam like.(i.e. I can get the screen display by VideoCapture in OpenCV.) Can someone tell me which video capture card should I buy? Thanks !!! 回答1: I do not know if there some way to achieve that directly using OpenCV. However, a simple workaround could be like this: Using this software you can create new webcam that stream your