OpenCV

Drawing a line using centroid point in opencv

送分小仙女□ 提交于 2021-02-10 20:15:26
问题 How do I pass a line through the center of a contour? I have the center coordinates of my contour. 回答1: This is how you solve this question - Original image - Result image - You first need to do basic filtering and find the contour. Then - 1) Find out the area of contour (minAreaRect) 2) Extract points from the contour (BoxPoints) 3) Convert it to a numpy array (np.array) 4) Order the points (perspective.order_points) 5) Take out Top-left, Top-right, Bottom-right and Bottom-left(tl, tr, br,

“ImportError: DLL load failed: The specified module could not be found” getting this error when doing object detection

和自甴很熟 提交于 2021-02-10 18:50:05
问题 from imageai.Detection import ObjectDetection import os execution_path = os.getcwd() --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in () ----> 1 from imageai.Detection import ObjectDetection 2 import os 3 4 execution_path = os.getcwd() ~\Anaconda3\lib\site-packages\imageai\Detection__init__.py in () ----> 1 import cv2 2 3 from imageai.Detection.keras_retinanet.models.resnet import resnet50_retinanet 4 from imageai

C++ Video Stream detect FPS

核能气质少年 提交于 2021-02-10 18:47:06
问题 I try to get the correct fps of a video stream from an axis or eneo camera. rtsp://192.168.0.1:554/axis-media/media.amp I use cv::VideoCapture::get(CV_CAP_PROP_FPS); but with some cameras the result is invalid for example the result is 180000 but the correct value is 25. I have check it with wireshark and see the value in the SDP Protocol is correct. Media Attribute (a): framerate:25.000000 Which Information cv::VideoCapture::get read? 回答1: OpenCV Isn't very good at this sort of thing, and

building for macOS-x86_64 but attempting to link with file built for macOS-arm64

对着背影说爱祢 提交于 2021-02-10 18:00:25
问题 I wrote a code using c++ and OpenCV: #include <iostream> #include <time.h> #include <opencv2/opencv.hpp> #include <opencv2/highgui.hpp> using namespace std; int main() { ... return 0; } then I trying to Running my code on the terminal and build using g++: g++ $(pkg-config --cflags --libs opencv) -std=c++11 yourFile.cpp -o yourFileProgram but I get this error: ... ld: warning: ignoring file /opt/homebrew/Cellar/opencv/4.5.1_2/lib/libopencv_core.dylib, building for macOS-x86_64 but attempting

golf ball tracking in Python/Opencv with different color balls [closed]

穿精又带淫゛_ 提交于 2021-02-10 17:37:25
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . Improve this question Just looking for some suggestions on how to approach the problem of golf ball tracking with different color balls. I've explored using absdiff() to get the difference between frames to track the balls but it also picks up the player and club movement. Also, using

golf ball tracking in Python/Opencv with different color balls [closed]

本小妞迷上赌 提交于 2021-02-10 17:36:54
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . Improve this question Just looking for some suggestions on how to approach the problem of golf ball tracking with different color balls. I've explored using absdiff() to get the difference between frames to track the balls but it also picks up the player and club movement. Also, using

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

OpenCV(4.0.0) Python Error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function 'cv::binary_op'

我怕爱的太早我们不能终老 提交于 2021-02-10 16:27:17
问题 I am trying to apply mask on an image using opencv bitwise-not. I am able to achieve this result if I read both original and mask image in Greyscale mode, but it doesn't work on 3 channel images. I have read this thread OpenCV Python Error: error: (-215) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function cv::binary_op but my problem isn't shapes of arrays or mask not being in uint8 format. import cv2 import numpy as np img = cv2.imread("Original.png") # original image,

to rotate template image and perform template matching

匆匆过客 提交于 2021-02-10 15:51:57
问题 I want to rotate given template image at different angles (eg. 30, 60, 90, ...) and then I want to match the rotated images with a source image to detect objects using opencv functions (I'm writing C code)... How can I do this using opencv functions? Or is there any other solution? ya i'd searched SOF and that function is not passing rotated image to the main progrm. . . . . and the other code given in SOF continuously rotating the image. so using this we cant do teplate matching. is there

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