I have to capture a rectangle from the source nv12 picture and save it named ''roi.jpg" and then save the source picture named “src.jpg”
I modify the sample 05 ,the roi.jpg is ok but the src.jpg is not ok. Here is my code and the pictures ./jpeg_encode ~/src.nv12 1920 1080 ~/roi.jpg -f 2 jpeg_encode.7z (938.4 KB)
My idea is like that
jpegenc = NvJPEGEncoder::createJPEGEncoder("jpenenc");
jpegenc->setCropRect(100,100,200,300); //crop a rect
jpegenc->encodeFromFd(dst_dma_fd, JCS_YCbCr, &out_buf, out_buf_size, ctx.quality);
jpegenc->setCropRect(0,0,1920,1080); //crop a rect
jpegenc->encodeFromFd(dst_dma_fd, JCS_YCbCr, &src_buf, src_size, ctx.quality);
I don’t know if I can use the jpeg encoder like this?
Hi,
If the source resolution is identical(such as 1920x1080), you can create one NvJpegEncoder for encoding the source frames. And if cropped resolution is identical(such as 200x300), you can create the other NvJpegencoder to encode cropped frames. And please call NvBufferTransform() to crop ROI instead of calling setCropRect()
So that there are two NvJpegEncoders. One is for encoding 1920x1080 and the other is for encoding 200x300. And do cropping by calling NvBufferTransform()
Hi,
This use-case does not work properly. Will check with our teams and see if we can support it in future release. On current releases, please re-create NvJpegEncoder once the resolution changes.
That means if the resolution is not identical, i’d better to delete old jpegenc and create a new one and use NvBufferTransform to instead of setcrop()?