Skip to content

Commit

Permalink
add another example
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRi committed Nov 5, 2018
1 parent 5b47f6b commit af11300
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Binary file added markers/mark1to4_5cm_20x10cm.odp
Binary file not shown.
5 changes: 5 additions & 0 deletions markers1to4.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0.000,0.000,0.000
0.200,0.000,0.000
0.000,0.100,0.000
0.200,0.100,0.000

10 changes: 4 additions & 6 deletions vmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ def __init__(self,markernum=5,K=[],dist=[],markerpos_file="mpos1.csv"):
aruco = cv2.aruco
self.dictionary = aruco.getPredefinedDictionary(aruco.DICT_6X6_250)
#self.startvideo()
self.mnum = markernum
self.setmarker(markerpos_file)
self.K = K
self.dist = dist
self.mnum = markernum
self.tvecs = []
self.rvecs = []
self.R = []

def setmarker(self,fname):
#self.objp = np.zeros((markernum,3), np.float32)
self.objp = np.loadtxt(fname,delimiter=",")
self.mnum,_ = self.objp.shape

def startvideo(self,vnum=0):
self.cap = cv2.VideoCapture(0)
Expand Down Expand Up @@ -116,17 +117,14 @@ def drawaxis(self,frame):#30cm cube
# load camera matrix and distort matrix
K = np.loadtxt("calib_usb/K.csv",delimiter=",")
dist_coef = np.loadtxt('calib_usb/d.csv',delimiter=",")
vm = vmarker(K=K,dist=dist_coef)
vm = vmarker(K=K,dist=dist_coef,markerpos_file="markers1to4.csv")
try:
while ~cap.isOpened():
ok,frame = cap.read()
nframe = cv2.undistort(frame, K, dist_coef)
#detect = detect_marker(frame)
#cv2.imshow("detected",detect)
#cv2.waitKey(1)
tv = vm.getcamerapose(frame)
print(tv)
#print(vm.R)
#print(vm.rvec) #euler angle

except KeyboardInterrupt:
print("Finish Program!")
Expand Down

0 comments on commit af11300

Please sign in to comment.