标签: aruco

AttributeError:模块“cv2.aruco”没有属性“Dictionary_get”

AttributeError:模块“cv2.aruco”没有属性“Dictionary_get”

即使安装后

  • OpenCV-Python
  • opencv-contrib-python
import numpy as np
import cv2, PIL
from cv2 import aruco
import matplotlib.pyplot as plt
import matplotlib as mpl
import pandas as pd

vid = cv2.VideoCapture(0)

while (True):

    ret, frame = vid.read()
    #cv2.imshow('frame', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    parameters =  aruco.DetectorParameters()
    corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)
    frame_markers = aruco.drawDetectedMarkers(frame.copy(), corners, ids)

    plt.figure()
    plt.imshow(frame_markers)
    for i in range(len(ids)):
        c = corners[i][0]
        plt.plot([c[:, 0].mean()], [c[:, 1].mean()], …
Run Code Online (Sandbox Code Playgroud)

python opencv aruco

9
推荐指数
2
解决办法
4万
查看次数

Python opencv Aruco"没有名为'cv2.aruco'的模块"

我正在运行一个带有Python 3.6.1,Anaconda 4.4.0(64位)的Ubuntu虚拟机.我想在这个网站上运行代码.当我尝试使用时

import cv2.aruco

我明白了:

>>> import cv2.aruco
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2.aruco'
Run Code Online (Sandbox Code Playgroud)

这是我需要安装或设置的东西吗?

opencv python-import python-3.x aruco

8
推荐指数
5
解决办法
1万
查看次数

cv2.aruco.detectMarkers在python中没有检测到标记

我的相机校准和失真矩阵,从aruco_calibration_fromimages.exe获得:

 [[3.19439125e+03   0.00000000e+00   1.98509417e+03]  
  [0.00000000e+00   3.20213561e+03   1.55099552e+03]  
  [0.00000000e+00   0.00000000e+00   1.00000000e+00]]

 [[0.1395281  -0.38313647  0.00505558  0.00237535  0.33952515]]
Run Code Online (Sandbox Code Playgroud)

图片,我试图检测:

在此输入图像描述

aruco_simple.exe成功

在此输入图像描述

但是python代码找不到任何东西:

fs = cv2.FileStorage("./calib_asus_chess/cam_calib_asus.yml", cv2.FILE_STORAGE_READ)
cam_mat=fs.getNode("camera_matrix").mat()
dist_mat=fs.getNode("distortion_coefficients").mat()
gray=cv2.imread('C:\\Users\\steve\\Dropbox\\Projects\\kinnekt\\laser\\aruco_frames\\shot1.jpg',0)
adict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_ARUCO_ORIGINAL)
res = cv2.aruco.detectMarkers(gray,dictionary=adict,cameraMatrix=cam_mat,distCoeff=dist_mat)
Run Code Online (Sandbox Code Playgroud)

由于某种原因,res [0]是空数组.为什么python版本失败?感谢名单!

python opencv aruco

8
推荐指数
1
解决办法
2494
查看次数

如何生成 ChAruco 板校准?

如何生成 ChAruco 板校准?我试图在 Google 搜索中找到现有的图板,但找不到。

谢谢,卡洛斯

opencv aruco

7
推荐指数
2
解决办法
7161
查看次数

我可以根据旋转/平移向量创建变换矩阵吗?

我正在尝试去掉具有已知大小元素的图像.鉴于此图片:

来源图片

我可以使用aruco:: estimatePoseBoard它返回旋转和平移向量.有没有办法利用这些信息去除与标记板在同一平面上的所有东西?(不幸的是,我的线性代数充其量是最基本的.)

澄清

我知道如何去除标记板.我想要做的是在与标记板相同的平面上去除其他东西(在这种情况下,云形物体).我正在试图确定这是否可行,如果是,那该怎么做.我已经可以在我想要偏斜的物体周围放置四个标记,并使用检测到的角作为输入getPerspectiveTransform以及它们之间的已知距离.但对于我们的实际应用,用户可能难以准确地放置标记.如果他们可以在框架中放置单个标记板并使软件偏移其他对象,则会容易得多.

c++ opencv matrix aruco

6
推荐指数
1
解决办法
893
查看次数

平均多个旋转矩阵的正确方法是什么?

我从许多帧的姿态估计中获得许多旋转向量(当相机静止时),并且我想要最准确的测量。理论上我可以通过旋转向量\矩阵\其他类型的数据进行平均吗?或者这是错误的?另外,我如何判断旋转向量\矩阵何时是异常值(即与所有其他值非常不同,并且可能是计算错误)?例如,在翻译矩阵中,我看到每个条目的厘米差异,并且可以有一个直观的阈值。旋转有类似的方法吗?

opencv matrix aruco opencv3.0

6
推荐指数
2
解决办法
8687
查看次数

Fundamental understanding of tvecs rvecs in OpenCV-ArUco

I want to use ArUco to find the "space coordinates" of a marker. I have problems understanding the tvecs and rvecs. I came so far as to the tvecs are the translation and the rvecs are for rotation. But how are they oriented, in which order are they written in the code, or how do I orient them?

Here is a little sketch of the setup. I have a camera (laptop webcam just drawn to illustrate the orientation of …

python opencv orientation marker aruco

6
推荐指数
1
解决办法
3941
查看次数

opencv charuco相机校准不会正确扭曲

我在使 Charuco 相机校准正常工作时遇到了一些麻烦。据我所知,我做的一切都是正确的,但最终未失真的图像比预期的扭曲得多。它确实适用于 4x4 板,但校正的区域太小,因此我需要使其适用于 7x7 板。如果有人能看到我做错了什么,非常感谢帮助,我现在有点卡住了。所以情况是这样的:

我设置了 4 个相机,每个相机都需要校准。我每个相机都有 11 张 charuco 板 7x7_1000 的照片,所以总共 44 张图像

这些是原始图像(适用于所有相机):

图片描述

根据我在教程中的理解*,并不是所有标记都需要可见,charuco 相机校准才能工作(这是 charuco bord 的整个想法)所以据我所知,源图像很好。

我检索每个相机图像集的标记和插值棋盘角,并将它们提供给 v2.aruco.calibrateCameraCharuco 函数。一切看起来都很好,正如这张带有除一个标记之外的所有标记的图像所示:

图片描述

于是我继续调用cv2.un Distort函数,但结果不是我所期望的:

图片描述

这是我根据教程中的示例编写的代码:

def draw_charuco_board( filename, board, size=(2000, 2000) ):
    imboard = board.draw(size)
    cv2.imwrite(filename, imboard)


def detect_charuco_corners( full_board_image_gray, board ):
    parameters = cv2.aruco.DetectorParameters_create()
    return cv2.aruco.detectMarkers(full_board_image_gray, board.dictionary, parameters=parameters)


def charuco_camera_calib( board, filename_glob_pattern, do_flip=False, flip_axis=0 ):
    """
    calibrates the camera using the charuco board
    @see https://docs.opencv.org/trunk/d9/d6a/group__aruco.html#ga54cf81c2e39119a84101258338aa7383
    @see https://github.com/opencv/opencv_contrib/blob/master/modules/aruco/samples/calibrate_camera_charuco.cpp
    """
    charuco_corners = []
    charuco_ids = [] …
Run Code Online (Sandbox Code Playgroud)

opencv camera-calibration aruco

6
推荐指数
1
解决办法
2048
查看次数

aruco::detectMarkers 没有找到标记的真正边缘

我正在使用 ArUco 标记来校正透视图并计算图像中的大小。在此图像中,我知道标记外边缘之间的确切距离,并使用它来计算黑色矩形的大小。

我的问题是aruco::detectMarkers并不总是识别标记的真实边缘(如细节图像中所示)。当我根据标记的角校正透视时,会导致失真,从而影响图像中对象的大小计算。

有没有办法提高 的边缘检测精度aruco::detectMarkers

这是整个电路板的缩小照片:

记号板

这是左下角标记的详细信息,显示了边缘检测的不准确性:

左下标记

以下是右上角标记的详细信息,显示了对同一标记 ID 的准确边缘检测:

在此处输入图片说明

在这个缩小的图像中很难看到,但左上角的标记准确,右下角的标记不准确。

我的函数调用detectMarkers

bool findMarkers(const Mat image, Point2d outerMarkerCoordinates[], Point2d innerMarkerCoordinates[], Size2d *boardSize) {
    Ptr<aruco::Dictionary> theDictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_1000);
    vector<vector<Point2f> > markers;
    vector<int> ids;

    aruco::detectMarkers(image, theDictionary, markers, ids);

    aruco::drawDetectedMarkers(image, markers, ids);

    return true; //There's actually more code here that makes sure there are four markers.
}
Run Code Online (Sandbox Code Playgroud)

opencv aruco

5
推荐指数
1
解决办法
3045
查看次数

Aruco OpenCV 示例,所有标记都被拒绝

我正在关注这个例子。

带有图像的 OpenCV Aruco 示例

以下是我用来检测标记的代码片段。我无法理解为什么这个例子对我不起作用。

import numpy as np
import cv2
import cv2.aruco as aruco
import os

im_names = filter(lambda x: x.endswith('.png'),
                  [f for f in os.listdir('local_vids_ims')])

for imn in im_names:
    image = cv2.imread('local_vids_ims/' + imn)
    # image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    parameters = aruco.DetectorParameters_create()
    corners, ids, rejectedImgPoints = aruco.detectMarkers(
        image, aruco_dict, parameters=parameters)
    print(corners, ids, rejectedImgPoints)
    # aruco.drawDetectedMarkers(image, corners)
    aruco.drawDetectedMarkers(image, rejectedImgPoints)
    cv2.imshow('gray_im', image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

上述代码的本地运行,所有标记都被拒绝。

opencv image-processing python-3.x aruco

5
推荐指数
1
解决办法
3418
查看次数