Export bag of CompressedImage to disk without decoding
I have a bag of compressed images (/camera/image/compressed). I wrote a Python script which reads the bagfile using the Python API and writes JPEGs to disk in this way:
cv_img = bridge.compressed_imgmsg_to_cv2(msg, desired_encoding="passthrough")
cv2.imwrite(file_name, cv_img)
However, the image quality is not that great. I looked at the source and the compressed_imgmsg_to_cv2
function calls cv2.imdecode
. So, essentially, I'm compressing the image twice. Is there a way around this using cvbridge? Should I just use PNG instead?