Comments (2)
I got it to work by modifying the numpy_to_k4a_image
to support K4A_IMAGE_FORMAT_COLOR_MJPG datatype.
For my usage width_pixels
and height_pixels
parameters are just hardcoded there for MJPG data in the snippet below (requires refactor).
k4a_result_t numpy_to_k4a_image(PyArrayObject *img_src, k4a_image_t *img_dst, k4a_image_format_t format) {
int width_pixels = img_src->dimensions[1];
int height_pixels = img_src->dimensions[0];
int pixel_size;
int stride_bytes;
int buffer_size;
switch (format) {
case K4A_IMAGE_FORMAT_DEPTH16:
case K4A_IMAGE_FORMAT_CUSTOM16:
case K4A_IMAGE_FORMAT_IR16:
pixel_size = (int)sizeof(uint16_t);
stride_bytes = width_pixels * pixel_size;
buffer_size = width_pixels * height_pixels * pixel_size;
break;
case K4A_IMAGE_FORMAT_COLOR_BGRA32:
pixel_size = (int)sizeof(uint32_t);
stride_bytes = width_pixels * pixel_size;
buffer_size = width_pixels * height_pixels * pixel_size;
break;
case K4A_IMAGE_FORMAT_CUSTOM8:
pixel_size = (int)sizeof(uint8_t);
stride_bytes = width_pixels * pixel_size;
buffer_size = width_pixels * height_pixels * pixel_size;
break;
case K4A_IMAGE_FORMAT_COLOR_MJPG:
pixel_size = (int)sizeof(uint8_t);
stride_bytes = 0;
buffer_size = width_pixels * height_pixels * pixel_size;
width_pixels = 1920;
height_pixels = 1080;
break;
default:
// Not supported
return K4A_RESULT_FAILED;
}
return k4a_image_create_from_buffer(format, width_pixels, height_pixels, stride_bytes,
(uint8_t *)img_src->data, buffer_size, NULL, NULL,
img_dst);
}
I think that the best way to pass them down would be to add another parameter to k4a_module.capture_set_color_image
call in color.setter
for color_resolution. That will require further change to numpy_to_k4a_image
- as in case of K4A_IMAGE_FORMAT_COLOR_MJPG color resolution is not the same as img_src->dimensions
.
Tested the setter for BGRA and MJPG data.
Would any of the authors be interested in checking if that's the right approach?
from pyk4a.
I'm not sure if this helps, but perhaps you need to decode the compressed MJPG data into BGRA32 format first, e.g., using array_color = cv2.cvtColor(cv2.imdecode(capture.color, cv2.IMREAD_COLOR), cv2.COLOR_BGR2BGRA)
? I ran into similar issues with MJPG vs. BGRA32, so perhaps this comment/issue could help: #164 (comment)
from pyk4a.
Related Issues (20)
- --external-sync flag in pyk4a HOT 2
- issues with pyk4a installation HOT 2
- Depth image counts to units conversion HOT 2
- ERROR: Could not build wheels for pyk4a, which is required to install pyproject.toml-based projects HOT 3
- Bug WFOV_UNBINNED depth configuration returns error HOT 4
- ERROR: Body tracking branch installation fails HOT 1
- Cannot import k4a_module.
- Question about pyk4a.PyK4APlayback () HOT 2
- how can i change camera settings?
- Error code 1120: not able to install pyk4a HOT 1
- calibration HOT 1
- align rgb and depth HOT 1
- cap.color and cap.transformed_depth are not sync HOT 3
- poetry install issue HOT 2
- How to only record RGB and trasnformed depth? HOT 1
- Transformed Depth Image - Depth value experimental setup HOT 1
- specify the path for my k4a.dll HOT 1
- Is it possible to use pyk4a with Jetson Nano 4GB?
- how to set the iso like whitebalance or exposure in pyk4a.py? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyk4a.