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

Support MJPG #178

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Support MJPG #178

wants to merge 8 commits into from

Conversation

msqiu
Copy link

@msqiu msqiu commented Sep 20, 2022

The default record format of Azure Kinect is MJPG, and the provided transformation format is BGRA. The convert function is provided here.

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
Comment on lines 175 to 179
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])
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

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

Copy link
Contributor

@shagren shagren left a 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 "
Copy link
Collaborator

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
@lpasselin
Copy link
Collaborator

lpasselin commented Sep 21, 2022

Damm this requires adding opencv as a dependency!
Should we replace by a comment pointing to a utility file?

@msqiu
Copy link
Author

msqiu commented Sep 22, 2022

Damm this requires adding opencv as a dependency! Should we replace by a comment pointing to a utility file?

IDK. The problem is that the default record format is MJPG and it is necessary to use BGRA for processing. Thanks to Microsoft:(

@shagren
Copy link
Contributor

shagren commented Sep 22, 2022

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.

@msqiu
Copy link
Author

msqiu commented Sep 22, 2022

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...

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

Successfully merging this pull request may close these issues.

3 participants