Skip to content

Commit

Permalink
Merge branch 'validator' into dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
goldbattle committed May 3, 2022
2 parents c04c6e9 + fc62fc7 commit 76908bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CameraChainValidator(object):
edge["A"][cidx_dest] = self.prepareStereoRectificationMaps(cidx_src, cidx_dest)

#register the callback for the synchronized images
sync_sub = message_filters.TimeSynchronizer([val.image_sub for val in self.monovalidators],1)
sync_sub = message_filters.ApproximateTimeSynchronizer([val.image_sub for val in self.monovalidators], 10, 0.02)
sync_sub.registerCallback(self.synchronizedCallback)

#initialize message throttler
Expand All @@ -120,7 +120,7 @@ class CameraChainValidator(object):

#convert image to numpy
try:
if (msg.encoding == "rgb8"):
if (msg.encoding == "rgb8" or msg.encoding == "bgra8"):
cv_image = np.squeeze(np.array(self.bridge.imgmsg_to_cv2(msg, "mono8")))
else:
cv_image = self.bridge.imgmsg_to_cv2(msg)
Expand Down Expand Up @@ -192,7 +192,7 @@ class CameraChainValidator(object):
def generatePairView(self, camAnr, camBnr):
#prepare the window
windowName = "Rectified view (cam{0} and cam{1})".format(camAnr, camBnr)
cv2.namedWindow(windowName, 1)
cv2.namedWindow(windowName, cv2.WINDOW_AUTOSIZE)

#get the mono validators for each cam
camA = self.monovalidators[camAnr]
Expand Down Expand Up @@ -378,7 +378,6 @@ class MonoCameraValidator(object):

self.topic = camConfig.getRosTopic()
self.windowName = "Camera: {0}".format(self.topic)
cv2.namedWindow(self.windowName, 1)

#register the cam topic to the message synchronizer
self.image_sub = message_filters.Subscriber(self.topic, Image)
Expand All @@ -400,6 +399,7 @@ class MonoCameraValidator(object):


def generateMonoview(self, np_image, observation, obs_valid):
cv2.namedWindow(self.windowName, cv2.WINDOW_AUTOSIZE)
np_image = cv2.cvtColor(np_image, cv2.COLOR_GRAY2BGR)

if obs_valid:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def distort(image, distortion_model, distortion_coeffs, focal_lengths,
distortion_coeffs)
distorted = denormalize(distorted_normalized, focal_lengths,
principal_point)
if (int(distorted[0]) < 0 or int(distorted[0]) > image.shape[0] or
int(distorted[1]) < 0 or int(distorted[1]) > image.shape[1]):
if (int(distorted[0]) < 0 or int(distorted[0]) >= image.shape[0] or
int(distorted[1]) < 0 or int(distorted[1]) >= image.shape[1]):
continue
distorted_image[int(distorted[0]), int(distorted[1])] = image[i,j]
return distorted_image
Expand Down

0 comments on commit 76908bd

Please sign in to comment.