Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add python charuco sample#23139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@AleksandrPanov
Copy link
Contributor

@AleksandrPanovAleksandrPanov commentedJan 15, 2023
edited
Loading

Added python sample to detect charuco board.

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@AleksandrPanov
Copy link
ContributorAuthor

AleksandrPanov commentedJan 15, 2023
edited
Loading

works with choriginal.jpg:
choriginal
tutorial_camera_charuco.yml.txt

args:
-w=5 -h=7 -sl=0.04 -ml=0.02 -d=10 -v=choriginal.jpg

result:
image

To correctly works withmatchImagePoints need merge PR#23138

@satpalsr
Copy link

satpalsr commentedJan 18, 2023
edited
Loading

Hey@AleksandrPanov , can you share how you generated charuco board? Specially want to fit on A4 paper size.

@AleksandrPanov
Copy link
ContributorAuthor

AleksandrPanov commentedJan 18, 2023
edited
Loading

Hey@satpalsr, you can use code from this sample:

import cv2 as cvfrom cv2 import arucoprint(cv.__version__)"setup"arucoDict = aruco.getPredefinedDictionary(aruco.DICT_6X6_250)"create the charuco board"calibration_board = aruco.CharucoBoard((5, 7), squareLength=0.072, markerLength=0.062, dictionary=arucoDict)board_image = calibration_board.generateImage((500, 700))cv.imwrite("sample_board.png", board_image)

@AleksandrPanovAleksandrPanovforce-pushed theadd_py_charuco_sample branch 2 times, most recently fromf80907a to0a649e5CompareJanuary 19, 2023 16:50
@asmorkalov
Copy link
Contributor

Current version of sample fails with exception, when Charuco board is shown to camera:

[ WARN:0@1.571] global cap_gstreamer.cpp:1728 open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1Traceback (most recent call last):  File "./aruco_detect_board_charuco.py", line 110, in <module>    main()  File "./aruco_detect_board_charuco.py", line 95, in main    if len(charuco_ids) > 0:TypeError: object of type 'NoneType' has no len()

@AleksandrPanov
Copy link
ContributorAuthor

addNoneType checks

Now sample must works in all cases:
part charuco corners:
image
full charuco corners:
image
and also works without charuco corners

(Uses PR#23138)

@AleksandrPanovAleksandrPanov marked this pull request as draftJanuary 20, 2023 15:15
@AleksandrPanovAleksandrPanov marked this pull request as ready for reviewJanuary 20, 2023 15:24
@AleksandrPanov
Copy link
ContributorAuthor

AleksandrPanov commentedJan 20, 2023
edited
Loading

I check sample with camera and add new condition to correct work with solvePnP():
if len(cam_matrix) > 0 and len(charuco_ids) >= 4:

@satpalsr
Copy link

Also addif len(obj_points) >= 6:

Otherwise I get

    flag, rvec, tvec = cv.solvePnP(obj_points, img_points, cam_matrix, dist_coefficients)cv2.error: OpenCV(4.7.0) /io/opencv/modules/calib3d/src/calibration.cpp:1173: error: (-2:Unspecified error) in function 'void cvFindExtrinsicCameraParams2(const CvMat*, const CvMat*, const CvMat*, const CvMat*, CvMat*, CvMat*, int)'> DLT algorithm needs at least 6 points for pose estimation from 3D-2D point correspondences. (expected: 'count >= 6'), where>     'count' is 4> must be greater than or equal to>     '6' is 6

@satpalsr
Copy link

Also, would be cool to add Charuco camera calibration script/function.

Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please take a look on already maintained samples in the main repository.

@AleksandrPanovAleksandrPanovforce-pushed theadd_py_charuco_sample branch 2 times, most recently frome031712 tofaa479dCompareJanuary 27, 2023 00:53
@asmorkalov
Copy link
Contributor

@alalek Could you take a look again? May the PR be merged?

@AleksandrPanovAleksandrPanovforce-pushed theadd_py_charuco_sample branch 2 times, most recently fromf42d9db to3960ca2CompareMarch 13, 2023 12:07
@asmorkalovasmorkalov self-requested a reviewMarch 13, 2023 12:54
@asmorkalovasmorkalov added this to the4.8.0 milestoneMar 15, 2023
@asmorkalovasmorkalov merged commit86fa030 intoopencv:4.xMar 15, 2023
@asmorkalovasmorkalov mentioned this pull requestMay 31, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asmorkalovasmorkalovasmorkalov approved these changes

@alalekalalekalalek left review comments

Assignees

@AleksandrPanovAleksandrPanov

Projects

None yet

Milestone

4.8.0

Development

Successfully merging this pull request may close these issues.

4 participants

@AleksandrPanov@satpalsr@asmorkalov@alalek

[8]ページ先頭

©2009-2025 Movatter.jp