mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
samples: fix python samples compatibility with demo.py
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
import matplotlib.pyplot as plt
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
from matplotlib import cm
|
||||
from numpy import linspace
|
||||
import argparse
|
||||
import cv2 as cv
|
||||
|
||||
from numpy import linspace
|
||||
|
||||
def inverse_homogeneoux_matrix(M):
|
||||
R = M[0:3, 0:3]
|
||||
T = M[0:3, 3]
|
||||
@@ -119,6 +119,8 @@ def create_board_model(extrinsics, board_width, board_height, square_size, draw_
|
||||
def draw_camera_boards(ax, camera_matrix, cam_width, cam_height, scale_focal,
|
||||
extrinsics, board_width, board_height, square_size,
|
||||
patternCentric):
|
||||
from matplotlib import cm
|
||||
|
||||
min_values = np.zeros((3,1))
|
||||
min_values = np.inf
|
||||
max_values = np.zeros((3,1))
|
||||
@@ -158,6 +160,8 @@ def draw_camera_boards(ax, camera_matrix, cam_width, cam_height, scale_focal,
|
||||
return min_values, max_values
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Plot camera calibration extrinsics.',
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument('--calibration', type=str, default='left_intrinsics.yml',
|
||||
@@ -179,6 +183,9 @@ def main():
|
||||
camera_matrix = fs.getNode('camera_matrix').mat()
|
||||
extrinsics = fs.getNode('extrinsic_parameters').mat()
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.gca(projection='3d')
|
||||
ax.set_aspect("equal")
|
||||
@@ -211,6 +218,10 @@ def main():
|
||||
ax.set_title('Extrinsic Parameters Visualization')
|
||||
|
||||
plt.show()
|
||||
print('Done')
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__)
|
||||
main()
|
||||
cv.destroyAllWindows()
|
||||
|
||||
Reference in New Issue
Block a user