OpenCV

StereoCalibration in OpenCV on Python

断了今生、忘了曾经 提交于 2021-02-06 06:30:56
问题 I am new in OpenCV, and could not find normal tutorial for stereoCalibration on Python. If you have some samples, please share. I do single calibration for each of cameras, and i have next problem. The left one: The right one: PS: I'm doing Depth-map and by the metter of it, i received bad map. UPDATE: I have ported the C++ version from https://github.com/jayrambhia/Vision/blob/master/OpenCV/C%2B%2B/stereocalibrate.cpp Yeah, it has no error but it return only fully black images Ported cod:

StereoCalibration in OpenCV on Python

江枫思渺然 提交于 2021-02-06 06:30:50
问题 I am new in OpenCV, and could not find normal tutorial for stereoCalibration on Python. If you have some samples, please share. I do single calibration for each of cameras, and i have next problem. The left one: The right one: PS: I'm doing Depth-map and by the metter of it, i received bad map. UPDATE: I have ported the C++ version from https://github.com/jayrambhia/Vision/blob/master/OpenCV/C%2B%2B/stereocalibrate.cpp Yeah, it has no error but it return only fully black images Ported cod:

OpenCV: How to correctly apply morphologyEx operation?

扶醉桌前 提交于 2021-02-06 06:28:11
问题 I am having a problem regarding the kernel size for morphologyEx . I have some captcha images and I want to do the same operation on them and get the same final result. code : image = cv2.imread("Image.jpg") gray = cv2.cvtColor(image , cv2.COLOR_BGR2GRAY) ret, thresh1 = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU) k1 = np.ones((3,3)) k2 = np.ones((5,5)) bottom_image = cv2.morphologyEx(thresh1, cv2.MORPH_CLOSE, k1) bottom_image = 255-bottom_image bottom_image = remove_boxes

OpenCV: How to correctly apply morphologyEx operation?

扶醉桌前 提交于 2021-02-06 06:28:02
问题 I am having a problem regarding the kernel size for morphologyEx . I have some captcha images and I want to do the same operation on them and get the same final result. code : image = cv2.imread("Image.jpg") gray = cv2.cvtColor(image , cv2.COLOR_BGR2GRAY) ret, thresh1 = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU) k1 = np.ones((3,3)) k2 = np.ones((5,5)) bottom_image = cv2.morphologyEx(thresh1, cv2.MORPH_CLOSE, k1) bottom_image = 255-bottom_image bottom_image = remove_boxes

【走进OpenCV】霍夫变换检测直线和圆

大城市里の小女人 提交于 2021-02-06 01:12:34
小白导读 学习计算机视觉最重要的能力应该就是编程了,为了帮助小伙伴尽快入门计算机视觉,小白准备了【走进OpenCV】系列,主要帮助小伙伴了解如何调用OpenCV库,涉及到的知识点会做简单讲解。 本文主要借鉴Madcola发布在简书上的文章,转载请联系原作者,禁止二次转载。 我们如何在图像中快速识别出其中的圆和直线?一个非常有效的方法就是霍夫变换,它是图像中识别各种几何形状的基本算法之一。 霍夫线变换 霍夫线变换是一种在图像中寻找直线的方法。OpenCV中支持三种霍夫线变换,分别是标准霍夫线变换、多尺度霍夫线变换、累计概率霍夫线变换。 在OpenCV中可以调用函数HoughLines来调用标准霍夫线变换和多尺度霍夫线变换。HoughLinesP函数用于调用累积概率霍夫线变换。 我们都知道,二维坐标轴上表示一条直线的方程式y = a*x + b,我们想求出一条直线就得想方设法求出其中的a和b的值。如果用极坐标来表示就是 theta就是直线与水平线所成的角度,而rho就是圆的半径(也可以理解为原点到直线的距离),同样地,这两个参数也是表征一条直线的重要参数,确定他们俩了,也就确定一条直线了。正如下图所示。 在OpenCV里,我们只需调用HoughLines就是可以得到表征一条直线的这两个参数值! HoughLines用法 # include <iostream> # include

OpenCV Kalman filter

旧巷老猫 提交于 2021-02-05 20:10:38
问题 I have three gyroscope values, pitch, roll and yaw. I would like to add Kalman filter to get more accurate values. I found the opencv library, which implements a Kalman filter, but I can't understand it how is it really work. Could you give me any help which can help me? I didn't find any related topics on the internet. I tried to make it work for one axis. const float A[] = { 1, 1, 0, 1 }; CvKalman* kalman; CvMat* state = NULL; CvMat* measurement; void kalman_filter(float FoE_x, float prev_x

OpenCV 【二十二】霍夫线变换/霍夫圆变换

坚强是说给别人听的谎言 提交于 2021-02-05 16:38:00
目录 1. 霍夫线变换¶ 1.1 原理 1.2 霍夫线性变换 1.3 标准霍夫线变换和统计概率霍夫线变换¶ 1.4 代码 1.5运行结果 2 .霍夫圆变换¶ 2.1 原理¶ 2.2霍夫圆变换¶ 2.3代码 2.4 运行结果 1. 霍夫线变换 ¶ 使用OpenCV的以下函数 HoughLines 和 HoughLinesP 来检测图像中的直线. 1.1 原理 众所周知, 一条直线在图像二维空间可由两个变量表示. 例如: 在 笛卡尔坐标系: 可由参数: 斜率和截距表示. 在 极坐标系: 可由参数: 极径和极角表示 对于霍夫变换, 我们将用 极坐标系 来表示直线. 因此, 直线的表达式可为: 化简得: 一般来说对于点 , 我们可以将通过这个点的一族直线统一定义为: 这就意味着每一对 代表一条通过点 的直线. 如果对于一个给定点 我们在极坐标对极径极角平面绘出所有通过它的直线, 将得到一条正弦曲线. 例如, 对于给定点 and 我们可以绘出下图 (在平面 - ): 只绘出满足下列条件的点 and . 我们可以对图像中所有的点进行上述操作. 如果两个不同点进行上述操作后得到的曲线在平面 - 相交, 这就意味着它们通过同一条直线. 例如, 接上面的例子我们继续对点: , 和点 , 绘图, 得到下图: 这三条曲线在 - 平面相交于点 , 坐标表示的是参数对 ( ) 或者是说点 , 点 和点

convert Matrix of type CV_32FC1 to CV_64FC1

三世轮回 提交于 2021-02-05 14:36:53
问题 How do I convert a cv::Mat of type CV_32FC1 to the type CV_64FC1 (equivalent to a change from float to double)? I am opening a Matrix that was saved as XML ( cvSave ) but as a float. This means that the field <dt> has the value f in the file. I need to change it to d to open it. But I'd rather not do this, instead I'd like to open it directly as a Matrix with elements of type double, or convert it later from float to double. Below is my code for opening the file. /** Load cv::Mat from XML

How to properly use cv2.findContours() on opencv version 4.4.0.?

风格不统一 提交于 2021-02-05 12:00:25
问题 Im trying to use cv2.findContours() on opencv version 4.4.0. (Im using Python version 3.8.5) but it throws an error, I cant figure out. Im not sure whats wrong with the code. Here's some background: According to OpenCV the syntax for cv2.findContours() is as follows: Python: contours, hierarchy = cv.findContours( image, mode, method[, contours[, hierarchy[, offset]]] ) I looked for some examples to make sure how to properly implement it, heres what I found: example 1 _, contours, _ = cv2

OpenCV showing extra windows with black bar?

人走茶凉 提交于 2021-02-05 11:54:20
问题 I am working with OpenCV on Python and just from yesterday I encountered a very weird problem. When I call a very simple method, imshow() , the program always spawn additional windows which has the same name as the main one and a black bar at the central. Sometime, there is no extra window called, while sometime there are like 50 or 100 windows spawns in forever loop. It is very strange and I encountered it since yesterday, when I uninstalled the opencv-python library and downloaded opencv