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

RBG16 to Array #27

Open
DPastl opened this issue Jul 27, 2017 · 1 comment
Open

RBG16 to Array #27

DPastl opened this issue Jul 27, 2017 · 1 comment

Comments

@DPastl
Copy link

DPastl commented Jul 27, 2017

Hello,

I've been attempting to add the ability to convert to 16bit RGB values from RAW16bit images. Here's my code thus far:

def __array__(self):
    cdef np.ndarray r
    cdef np.npy_intp shape[3]
    cdef np.npy_intp stride[3]
    cdef np.dtype dtype
    fmt = self.fmt or self.img.format
    ndim = 2
    if fmt == PIXEL_FORMAT_MONO8 or fmt == PIXEL_FORMAT_RAW8:
        dtype = np.dtype("uint8")
        stride[1] = 1
    elif fmt == PIXEL_FORMAT_MONO16 or fmt == PIXEL_FORMAT_RAW16:
        dtype = np.dtype("uint16")
        stride[1] = 2
    elif fmt == PIXEL_FORMAT_RGB8 or fmt == PIXEL_FORMAT_444YUV8:
        dtype = np.dtype("uint8")
        ndim = 3
        stride[1] = 3
        stride[2] = 1
        shape[2] = 3
    elif fmt == PIXEL_FORMAT_RGB16:
        dtype = np.dtype("uint16")
        ndim = 3
        stride[1] = 6
        stride[2] = 2
        shape[2] = 3
    elif fmt == PIXEL_FORMAT_422YUV8:
        dtype = np.dtype("uint8")
        ndim = 3
        stride[1] = 2
        stride[2] = 1
        shape[2] = 2
    else:
        dtype = np.dtype("uint8")
        stride[1] = self.img.stride/self.img.cols

This isn't quite working out, I'm ending up with weird images. Do I perhaps have the stride or shape incorrect?

@jordens
Copy link
Owner

jordens commented Nov 24, 2019

Have you figured this one out or found help somewhere? I don't have access to a suitable camera or know what the dataformat is and how to transform it.

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

2 participants