Skip to content

Commit

Permalink
Improve some information
Browse files Browse the repository at this point in the history
  • Loading branch information
ruidong han committed Jul 6, 2019
1 parent c814693 commit 1404a3e
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 60 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,3 +34,4 @@ E-Mail:[email protected]
## 如何使用
1. 首先要安装opencv和其他python包。
2. 直接运行任意一个test开头的文件。
3. camtest是一些其他有关摄像头的工作,并没有完全完工。
Binary file added __pycache__/tagUtils.cpython-36.pyc
Binary file not shown.
8 changes: 7 additions & 1 deletion camtest/README.md
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.
45 changes: 0 additions & 45 deletions camtest/testMulPicso.py

This file was deleted.

23 changes: 9 additions & 14 deletions camtest/testcam.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import cv2
from apriltag import myapriltag
from apriltag import Apriltag
import numpy as np
import tagUtils as tud
# ap = myapriltag()
# ap.createDetector(debug=True)
# #filename = '3dpicture/0_0.jpg'
# filename = 'picture/1080p-40.jpg'
# frame = cv2.imread(filename)
# detections = ap.detector(frame)

def main():
cap = cv2.VideoCapture(0)
cap.set(3,1920)
cap.set(4,1080)
fps = 24
window = 'Camera'
cv2.namedWindow(window)
detector = myapriltag()
detector = Apriltag()
detector.createDetector(debug=False)


Expand All @@ -39,12 +34,12 @@ def main():
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))
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)

########################
Expand Down
56 changes: 56 additions & 0 deletions testcam.py
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()

0 comments on commit 1404a3e

Please sign in to comment.