Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw image is already JPEG compressed #73

Open
CBadam opened this issue Oct 7, 2024 · 2 comments
Open

Raw image is already JPEG compressed #73

CBadam opened this issue Oct 7, 2024 · 2 comments

Comments

@CBadam
Copy link

CBadam commented Oct 7, 2024

I am using the Orbbec Femto Mega to take one picture at a time (color, and depth).
this is how I configured the stream:

depth_profile_list = pipeline.get_stream_profile_list(OBSensorType.DEPTH_SENSOR)
depth_profile = profile_list.get_video_stream_profile(1024, 1024, OBFormat.Y16, 5)

color_profile_list = pipeline.get_stream_profile_list(OBSensorType.COLOR_SENSOR)
depth_profile = profile_list.get_video_stream_profile(1920, 1080, OBFormat.RGB, 5)

and this is the function I use to save the pictures:

def save_color_frame(self,color_frame, index, timestamp,dir_path):
        color_data = frame_to_bgr_image(color_frame)
        color_filename = os.path.join(dir_path, f"color_{index}_{timestamp}.png")
        cv2.imwrite(color_filename, color_data,[cv2.IMWRITE_PNG_COMPRESSION, 0])

def save_depth_frame(self,depth_frame, index, timestamp,dir_path):
        depth_data = np.frombuffer(depth_frame.get_data(), dtype=np.uint16).reshape((depth_frame.get_height(), depth_frame.get_width()))
        depth_data = (depth_data * depth_frame.get_depth_scale()).astype(np.uint16)
        depth_filename = os.path.join(dir_path, f"depth_{index}_{timestamp}.png")
        cv2.imwrite(depth_filename, depth_data,[cv2.IMWRITE_PNG_COMPRESSION, 0])

The depth image quality is excellent. But when I zoom in the color image with matplotlib for example, I can notice a blocks of 8 by 8 appearing which is a sign of JPEG compression. So I wanted to know how can I do to get raw color images.

@zhonghong322
Copy link
Contributor

zhonghong322 commented Oct 8, 2024

The RGB format in OBFormat.RGB is internally obtained by capturing a JPEG image and then decoding it into an RGB image. If you want to get the raw image, you can set it to output in YUV format (OBFormat.YUYV).

@hamamabrouk
Copy link

@zhonghong322 When will YUYV format be supported in net device? I find it only when I connect the femto mega via USB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants