Tips for using OpenCV and Cameras
Read CompressedImage type
from cv_bridge import CvBridge
def __init__(self):
self.bridge = CvBridge()
def image_callback(self, msg):
# get raw image
# image = self.bridge.imgmsg_to_cv2(msg)
# get compressed image
np_arr = np.frombuffer(msg.data, np.uint8)
img_np = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
image = cv2.cvtColor(img_np, cv2.COLOR_BGR2HSV)Limit frame rate
def __init__(self):
self.counter = 1
def image_callback(self, msg):
# set frame rate 1/3
if self.counter % 3 != 0:
self.counter += 1
return
else:
self.counter = 1Republish the image
Last updated
Was this helpful?
