-
Notifications
You must be signed in to change notification settings - Fork 82
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
Support MJPG #178
base: develop
Are you sure you want to change the base?
Support MJPG #178
Conversation
The default record format of Azure Kinect is MJPG, and the provided transformation format is BGRA. The convert function is provided here.
pyk4a/capture.py
Outdated
color_BGR = cv2.imdecode(self._color, cv2.IMREAD_COLOR) | ||
b, g, r = cv2.split(color_BGR) | ||
h, w = b.shape | ||
a = np.ones((h, w), dtype=np.uint8)*255 | ||
color_BGRA = cv2.merge([b, g, r, a]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use something like
cv2.cvtColor(color_BGR, cv2.COLOR_BGR2BGRA)
pyk4a/capture.py
Outdated
"color color_image must be of color_format K4A_IMAGE_FORMAT_COLOR_BGRA32 for " | ||
"transformation_color_image_to_depth_camera" | ||
) | ||
if self._color_format == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better if you use constants insteads numbers i.e. ImageFormat.COLOR_MJPG
pyk4a/capture.py
Outdated
"color color_image must be of color_format K4A_IMAGE_FORMAT_COLOR_BGRA32 for " | ||
"transformation_color_image_to_depth_camera" | ||
) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you missed other color formats, i.e. ImageFormat.COLOR_NV12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpasselin , looks good for me
color_BGRA = cv2.cvtColor(self._color, cv2.COLOR_YUV2BGRA_YUY2) | ||
elif self._color_format == ImageFormat.COLOR_BGRA32: | ||
color_BGRA = self.color | ||
else: | ||
raise RuntimeError( | ||
"color color_image must be of color_format K4A_IMAGE_FORMAT_COLOR_BGRA32 for " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the message here.
delete error message
Damm this requires adding opencv as a dependency! |
IDK. The problem is that the default record format is MJPG and it is necessary to use BGRA for processing. Thanks to Microsoft:( |
You can open camera with BGRA color_format, in this case mkv will store uncompressed bgra(or rgb, I forgot details). But file will be VERY HUGE. |
Not only huge, also impossible to capture at 30FPS on my laptop... |
The default record format of Azure Kinect is MJPG, and the provided transformation format is BGRA. The convert function is provided here.