Comments (5)
I adapted your script to use OpenCV's VideoCapture
class:
#!/usr/bin/env python3
import apriltag
import cv2
if __name__ == "__main__":
cam = cv2.VideoCapture()
if not cam.isOpened():
exit()
detector = apriltag.apriltag(family='tag36h11')
count = 0
while True:
_, image = cam.read()
cv2.imshow("image", image)
cv2.waitKey(1)
# print(f'Image {count}')
count += 1
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
dets = detector.detect(gray)
print(f"image {count}, detections", len(dets))
if len(dets) > 0:
print(f"detections", dets)
With the "Tag36h11" from https://april.eecs.umich.edu/media/apriltag/tagformats_web.png moving in and out of the camera I get a log like:
image 38, detections 0
image 39, detections 0
image 40, detections 0
image 41, detections 0
image 42, detections 1
detections ({'hamming': 1, 'margin': 95.90980529785156, 'id': 0, 'center': array([217.63509135, 132.08676829]), 'lb-rb-rt-lt': array([[167.09477234, 163.29779053],
[252.62365723, 179.94235229],
[266.43988037, 101.9475174 ],
[183.34217834, 85.18266296]])},)
image 43, detections 1
detections ({'hamming': 0, 'margin': 105.45146179199219, 'id': 0, 'center': array([223.41219345, 125.66384523]), 'lb-rb-rt-lt': array([[171.00808716, 157.98808289],
[259.49859619, 175.00976562],
[274.39813232, 94.21437073],
[187.78811646, 76.95012665]])},)
image 44, detections 1
detections ({'hamming': 0, 'margin': 107.93148040771484, 'id': 0, 'center': array([227.28037937, 119.98327687]), 'lb-rb-rt-lt': array([[173.24375916, 153.52482605],
[264.44946289, 171.06555176],
[279.59329224, 87.51166534],
[190.35250854, 69.2325058 ]])},)
[...]
image 74, detections 1
detections ({'hamming': 0, 'margin': 109.63236236572266, 'id': 0, 'center': array([186.29173532, 141.22647609]), 'lb-rb-rt-lt': array([[125.28643799, 190.19546509],
[235.91940308, 200.60371399],
[246.70794678, 92.73034668],
[136.07653809, 81.14628601]])},)
image 75, detections 1
detections ({'hamming': 0, 'margin': 103.26177215576172, 'id': 0, 'center': array([178.18746309, 147.52838709]), 'lb-rb-rt-lt': array([[119.40704346, 196.05543518],
[225.92948914, 205.7492218 ],
[235.50740051, 100.20706177],
[130.6658783 , 89.57637787]])},)
image 76, detections 0
image 77, detections 0
image 78, detections 0
image 79, detections 0
image 80, detections 0
image 81, detections 0
For me, the Python bindings work even when the detections disappear. Are you seeing this issue only on the Raspberry Pi? Can you reproduce this with my adapted script on a different PC?
from apriltag.
The python bindings worked fine with OpenCV or Pillow. But when I started a picamera2 capture, I would always get the error with spinning up threads. Although it did seem to process one frame, but the second frame would throw this error message. I write a small shared library that made the calls to the apriltag library and then used ctypes to expose the interface to my new shared library. That worked fine. I dug through the apriltag python interface, I don't see why it would fail to spin up the threads. When the FRC session is done, I might take a deeper look into this. Really weird.
from apriltag.
I can reproduce this now. However, I am sure this has nothing to do with the threads, but rather with something setting errno to EAGAIN
.
If I add something like perror("ERR");
at the beginning of apriltag_detect
, then this will already print No such file or directory
for the first image (Image 0
) and Resource temporarily unavailable
for the next image (Image 1
) without actually running any detection. So I would assume that the errno is set internally by something in capture_array()
.
You can work around this by printing something right after capture_array()
, e.g.:
img1 = picam2.capture_array()
print("")
will reset the errno and thus print ERR: Success
.
Maybe just resetting the errno at the beginning of apriltag_detect
would be a good way to make sure that we only consider errnos generated from function calls inside apriltag_detect
. But I also think that picamera2
should do better error checking.
from apriltag.
@nlbutts Can you check if #323 fixes your issue?
from apriltag.
That fixed the problem. So did the print("").
from apriltag.
Related Issues (20)
- Geometric interpretation of estimation error HOT 2
- Help with thresholding parameters HOT 1
- How to run pose estimation in python ? HOT 3
- compatibility with WIN32_LEAN_AND_MEAN HOT 8
- Anyone implmented c# wrapper for this? HOT 1
- error when i run make in ubuntu 22.04 HOT 1
- Has anyone confirmed that this library can work on ESP32S3? HOT 3
- How to use intrinsics in Scaramuzza format to estimate the apriltag pose? HOT 3
- Suggestions on improving detections in low light conditions HOT 4
- What's the meaning of 'apriltag.c:448: homography_compute2: Assertion `max_val_idx >= 0' failed.'? HOT 5
- Planned Python Package Index (PyPI) package? HOT 4
- Build fail on Ubuntu Noble in g2d.c: `last_quadrant` is used unitialized; treat-all-warnings-as-errors HOT 4
- How to detect AprilGrid? HOT 5
- (Python) 'Nthreads' is an invalid keyword argument for this function HOT 1
- Question: Use more than 4 points for pose computation HOT 3
- corner location has always 0.125 pixel error
- ReadMe File Error HOT 2
- Question: How to process moving frames? HOT 5
- from apriltag import apriltag no module HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apriltag.