我正在尝试找到一种方法来在 MatLab 中找到该二值图像上的角点
我一直在尝试找到一种方法来在该图像上拟合三角形并找到顶点。我尝试过寻找角点,但它返回的值并不总是正确的。
有什么方法可以锐化边缘,以便角函数可以返回更好的结果吗?
我很感激任何意见!谢谢!
什么策略看起来更简单、更有效?我可以使用哪些现有的 MatLab 函数?
matlab rounded-corners computational-geometry matlab-cvst corner-detection
我正在寻找一个程序,可以使用 Python 中的 OpenCV 准确检测扭曲矩形的角点。
我已经尝试通过谷歌搜索来解决不同的建议,但是通过直线的正弦叠加(参见阈值图像)我可能无法检测到角点。到目前为止,我尝试了 findContours 和 HoughLines,但没有取得好的结果。不幸的是我不明白Xu Bin关于如何使用opencv找到模糊角位置的C代码?
这是我的初始图像:
调整大小和阈值后,我应用精明的边缘检测来获得以下图像:

contours, hierarchy = cv2.findContours(g_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
box = cv2.minAreaRect(contour)
box = cv2.cv.BoxPoints(box) if imutils.is_cv2() else cv2.boxPoints(box)
box = np.array(box, dtype="float")
box = perspective.order_points(box)
Run Code Online (Sandbox Code Playgroud)
我仅通过一些额外的绘图得到以下结果:

我认为直线拟合是解决问题的好方法,但不幸的是我无法让 HoughLines 工作,并且在查看OpenCV Python - How to Implement RANSAC to detector Straightlines?之后我无法让 HoughLines 工作。RANSAC似乎也很难适用于我的问题。
非常感谢任何帮助。
我试图使用 opencv(python) 中的哈里斯角点检测来检测图像中的所有角点。但由于线的粗细,我在一个角上得到了多个角。我能做些什么来纠正这个问题吗?
代码
import numpy as np
import cv2 as cv
filename = 'Triangle.jpg'
img = cv.imread(filename)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv.imshow('dst',img)
if cv.waitKey(0) & 0xff == 27:
cv.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
python opencv image-processing computer-vision corner-detection
我有一组平假名字符,我想计算字符的端点/提示数量。
示例:输入图像:
所需的输出图像:
我试过使用凸包
代码:(基于此处的opencv教程)
findContours(threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
vector<vector<Point> >hull(contours.size());
for (int i = 0; i < contours.size(); i++)
{
convexHull(Mat(contours[i]), hull[i], false);
}
Mat drawing = Mat::zeros(threshold_output.size(), CV_8UC3);
for (int i = 0; i< contours.size(); i++)
{
if (hierarchy[i][3] == 0) {
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
drawContours(drawing, hull, i, color, 1, 8, vector<Vec4i>(), 0, Point());
}
}
Run Code Online (Sandbox Code Playgroud)
然后 conrnerHarris() 但它返回了太多不需要的角落
代码:(基于此处的opencv教程)
int blockSize = 2;
int …Run Code Online (Sandbox Code Playgroud) 我想测量房间表面积(以平方米为单位)并想使用 2D-Lidar 找出平面图。我怎样才能做到这一点?
在图片中,您可以看到很多点。每个点代表相对于激光雷达位置的角度和距离。这是数据集:
angle: 0 distance: 942
angle: 0.62 distance: 3469
angle: 1.25 distance: 3350
angle: 2.5 distance: 3410
angle: 3.12 distance: 3404
angle: 3.75 distance: 3403
angle: 4.37 distance: 3464
angle: 5 distance: 3441
angle: 5.62 distance: 3445
angle: 6.25 distance: 3444
angle: 6.87 distance: 3455
angle: 7.5 distance: 3464
angle: 8.12 distance: 3464
angle: 8.75 distance: 3477
angle: 9.37 distance: 3470
angle: 10 distance: 3504
angle: 10.62 distance: 3505
angle: 11.25 distance: 3505
angle: 11.87 distance: 3516 …Run Code Online (Sandbox Code Playgroud) 我在 Python 中使用 openCV 来找到一张纸的角点以使其变形。
img = cv2.imread(images[i])
corners = cv2.goodFeaturesToTrack(cv2.cvtColor(img,cv2.COLOR_BGR2GRAY),4,.01,1000,useHarrisDetector=True,k=.04)
corners = np.float32(corners)
print(corners)
ratio = 1.6
cardH = math.sqrt((corners[2][0][0] - corners[1][0][0]) * (corners[2][0][0] - corners[1][0][0]) + (corners[2][0][1] - corners[1][0][1]) * (
corners[2][0][1] - corners[1][0][1]))
cardW = ratio * cardH;
pts2 = np.float32(
[[corners[0][0][0], corners[0][0][1]], [corners[0][0][0] + cardW, corners[0][0][1]], [corners[0][0][0] + cardW, corners[0][0][1] + cardH],
[corners[0][0][0], corners[0][0][1] + cardH]])
M = cv2.getPerspectiveTransform(corners, pts2)
offsetSize = 500
transformed = np.zeros((int(cardW + offsetSize), int(cardH + offsetSize)), dtype=np.uint8);
dst = cv2.warpPerspective(img, M, …Run Code Online (Sandbox Code Playgroud) opencv computer-vision edge-detection python-3.x corner-detection
我在 python 中使用哈里斯角检测的 opencv 实现。我的问题是关于下面 gif 中显示的行为 - 当图像旋转时,角停止被检测到(在各种旋转时)。完整代码:
import cv2
image_path = 'image1.jpg'
original_image = cv2.imread(image_path)
def play(video, name='video', wait=60, key='q'):
for f in video:
cv2.imshow(name, f)
if cv2.waitKey(wait) == ord(key):
return
def rotate(image, theta, point=(0,0)):
M = cv2.getRotationMatrix2D((point[1], point[0]), theta, 1)
return cv2.warpAffine(image, M, (image.shape[1], image.shape[0]))
def rotate_detect(image):
for theta in range(0, 360):
img = rotate(image, theta, (original_image.shape[0] / 2, original_image.shape[1] / 2))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dst = cv2.cornerHarris(gray,9,13,0.04)
#result is dilated for marking the corners, not …Run Code Online (Sandbox Code Playgroud) 我最近使用Matlab 单摄像机校准应用程序算法来校准相机内在函数和外在函数.在找到棋盘的角落时,很多时候detectCheckerboardPointsMatlab的功能执行(准确性)opencv api cv::findChessboardCorners,但在某些图片上,Matlab表现得很奇怪.
例如,在下图中,可以清楚看到棋盘方块之间的角落,而matlab在奇怪的地方找到了多余的角落:
matlab代码片段很简单,如下所示:
img=imread(fn);
[imUndist, newOrig]=undistortImage(img, cameraParams);
[pxs, bdsize]=detectCheckerboardPoints(imUndist); %or detect on 'img' directly
imMarked=insertMarker(imUndist, pxs);
imshow(imMarked);
Run Code Online (Sandbox Code Playgroud)
opencv在此图像上检测到(下面的代码)的角非常精确:// opencv代码:
Mat img = imread(fpath);
int ww = 8, hh = 15;
cv::Size bsz(ww, hh);
vector<Point2f> ptvec;
bool found = cv::findChessboardCorners(img, bsz, ptvec, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE);
cv::drawChessboardCorners(img, bsz, ptvec, found);
imshow("img", img);
waitKey();
Run Code Online (Sandbox Code Playgroud)
matlab opencv camera-calibration extrinsic-parameters corner-detection
我发现此帖子OpenCV findChessboardCorners非常慢,但是它不能完全回答我的问题。
我在树莓派上运行相机校准工具,并且要花费大量时间来检测全分辨率图像中的棋盘角。我目前正在重新缩放它们,但是计算出的参数无法用于完整尺寸的图像。
我当时想做的一件事是在较小的图像中检测到角点4倍,然后将角点坐标乘以4,但结果却不尽相同。
您是否认为有办法加快或插入另一个拐角检测?
我正在使用python实现(cv2)
谢谢
corner-detection ×11
opencv ×9
python ×4
image ×3
matlab ×2
c++ ×1
convex-hull ×1
lidar ×1
matlab-cvst ×1
python-3.x ×1