Skip to content

Could you provide a usage example of the gpujpeg_encoder_input_set_gpu_image function? #113

Open

Description

@libaineu2004

gpujpeg_encoder.h

GPUJPEG_API void
gpujpeg_encoder_input_set_gpu_image(struct gpujpeg_encoder_input* input, uint8_t* image);

Could you provide a usage example of the gpujpeg_encoder_input_set_gpu_image function?
How should I fill in the input parameter uint8_t* image for this function? I want to pass cv::cuda::GpuMat image; from OpenCV as the parameter. How do I use it?

Activity

  1. MartinPulec commented on Nov 4, 2026

    @MartinPulec
    Collaborator

    It should be the normal pointer to device memory so provided that the image is on-device, I believe you'd need to pass there the cv::cuda::GpuMat::ptr()? An issue can be that OpenCV might have the buffer padded, while GPUJPEG expects it isn't. In this case set gpujpeg_image_parameters::width_padding passed to gpujpeg_encoder_encode(). I've grabbed an example from GLM itnt it seems legit to me:

    struct gpujpeg_image_parameters param_image = gpujpeg_default_image_parameter();
    param_image.width  = gmat.cols;
    param_image.height = gmat.rows;
    param_image.pixel_format = GPUJPEG_444_U8_P012;      // CV_8UC3
    param_image.color_space  = GPUJPEG_RGB;
    param_image.width_padding =
          (int)(gmat.step - (size_t)gmat.cols * gmat.elemSize());
    
    struct gpujpeg_encoder_input input;
    gpujpeg_encoder_input_set_gpu_image(&input, gmat.ptr());
    gpujpeg_encoder_encode(enc, &param, &param_image, &input, &out, &out_size);
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions