forked from BlackJocker1995/Apriltag_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ruidong han
committed
Jul 6, 2019
1 parent
c814693
commit 1404a3e
Showing
6 changed files
with
74 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ Just support tag36h11,tag25h9,tag16h5. | |
## How to use it | ||
1. You should install the opencv and other lib.Your python version must higher that 2.7(not support). | ||
2. Now you can run files starting with test*.py | ||
3. fold named camtest contains some operation about camera and aprilt,but it still not finished. | ||
|
||
|
||
## Other | ||
|
@@ -33,3 +34,4 @@ E-Mail:[email protected] | |
## 如何使用 | ||
1. 首先要安装opencv和其他python包。 | ||
2. 直接运行任意一个test开头的文件。 | ||
3. camtest是一些其他有关摄像头的工作,并没有完全完工。 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# Details | ||
These files which are Not related to the Apriltag program itself are used for real-time camera testing. | ||
These files which are Not related to the Apriltag program itself are used for real-time camera testing. | ||
|
||
## Works | ||
|
||
1. testcam(work) : detecting tag by camera.It can also calculate a distence between tag and camera that needs focal length and tag`size in real world. | ||
2. testMulPic(not work) : Use multiple cameras for spatial positioning.But need a specific experimental environment. | ||
3. vispytest(not work) : 3d visual platform. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import cv2 | ||
from apriltag import Apriltag | ||
import numpy as np | ||
import tagUtils as tud | ||
|
||
def main(): | ||
cap = cv2.VideoCapture(0) | ||
cap.set(3,1920) | ||
cap.set(4,1080) | ||
fps = 24 | ||
window = 'Camera' | ||
cv2.namedWindow(window) | ||
detector = Apriltag() | ||
detector.createDetector(debug=False) | ||
|
||
|
||
while cap.grab(): | ||
success, frame = cap.retrieve() | ||
if not success: | ||
break | ||
|
||
detections = detector.detect(frame) | ||
show = None | ||
if (len(detections) == 0): | ||
show = frame | ||
else: | ||
show = frame | ||
edges = np.array([[0, 1], | ||
[1, 2], | ||
[2, 3], | ||
[3, 0]]) | ||
for detection in detections: | ||
point = tud.get_pose_point(detection.homography) | ||
dis = tud.get_distance(detection.homography,122274) | ||
for j in range(4): | ||
cv2.line(show,tuple(point[edges[j,0]]),tuple(point[edges[j,1]]),(0,0,255),2) | ||
dete_point = np.int32(detection.corners) | ||
for j in range(4): | ||
cv2.line(show, | ||
tuple(dete_point[edges[j, 0]]), | ||
tuple(dete_point[edges[j, 1]]), | ||
color=(0,255,0)) | ||
print ('dis:' , dis) | ||
|
||
######################## | ||
num_detections = len(detections) | ||
cv2.imshow(window, show) | ||
k = cv2.waitKey(1000//int(fps)) | ||
|
||
if k == 27: | ||
break | ||
cap.release() | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|