Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion camera_calibration/src/camera_calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def __init__(self, boards, flags=0, fisheye_flags = 0, pattern=Patterns.Chessboa
self.pattern = pattern
self.br = cv_bridge.CvBridge()
self.camera_model = CAMERA_MODEL.PINHOLE
self.vga_scale = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a method to set this attribute ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another method has been added, just a simple way to set the scale

# self.db is list of (parameters, image) samples for use in calibration. parameters has form
# (X, Y, size, skew) all normalized to [0,1], to keep track of what sort of samples we've taken
# and ensure enough variety.
Expand Down Expand Up @@ -405,6 +406,9 @@ def get_parameters(self, corners, ids, board, size):
def set_cammodel(self, modeltype):
self.camera_model = modeltype

def set_vga_scale(self, scale):
self.vga_scale = scale

def is_slow_moving(self, corners, ids, last_frame_corners, last_frame_ids):
"""
Returns true if the motion of the checkerboard is sufficiently low between
Expand Down Expand Up @@ -535,7 +539,11 @@ def downsample_and_detect(self, img):
# Scale the input image down to ~VGA size
height = img.shape[0]
width = img.shape[1]
scale = math.sqrt( (width*height) / (640.*480.) )
if self.vga_scale == 0:
scale = math.sqrt((width * height) / (640. * 480.))
else:
scale = self.vga_scale

if scale > 1.0:
scrib = cv2.resize(img, (int(width / scale), int(height / scale)))
else:
Expand Down