Development Environment: arduino IDE
boards:spresense
I tried to find a way to clip only the QVGA YUV422 image obtained by video stream, but it has not been resolved.
I understand that the following functions can actually resize images and that there is a limitation from 14p of the URL destination that the magnification at resizing is 2^n times or 1/2^n times, and the size after resizing is an integer.
===========================================
·CamErrCamImage:resizeImageByHW
Image Resize
·CamErrCamImage:clipandResizeImageByHW
Image Clip + Resize
URL:Spresense Study meeting #1 How to use the Camera board
https://www.slideshare.net/YoshinoriOota/spresense-study-meeting1-how-to-use-the-camera-board
===========================================
For this reason, we are trying to check the operation using only the clip function with the code below.
Code Summary: QVGA (320,240) - Clip → (60,60) - Resize → (60,60)
CamImage small;
CamErrrr=img.clipAndResizeImageByHW(small//img:video stream image)
, 48, 8
, 107, 67
, 60, 60);
if(err)
{
Serial.println("ERROR:" + String(err)));
return;
}
if(!small.isAvailable())
{
Serial.println("clipAndResize failed";
return;
}
I actually checked the operation on the serial monitor, but no error code was displayed and
If n = 0, it does not work properly.
Q
such as QVGA (320,240) - Clip → (120,120) - Resize → (60,60)
We have verified normal operation when n=1 and so on.
The clipAndResizeImageByHW is defined in camera.cpp and is as follows:
Based on the code below, I understand that imageproc_clip_and_resize is the processing part that I want to focus on this time, but I can only see the header for this function, and I have not yet seen the definition.
CamErrCamImage::clipAndResizeImageByHW(
CamImage & img,
int lefttop_x,
int lefttop_y,
int rightbottom_x,
int rightbottom_y,
int width,
intheight)
{
int clip_width, clip_height;
imageproc_rect_tinrect;
// Input instance must not be Capture Frames.
if((img.is_valid())&(img.img_buff->cam_ref!=NULL))
{
return CAM_ERR_INVALID_PARAM;
}
// Format check.
if(getPixFormat()!=CAM_IMAGE_PIX_FMT_YUV422)
{
return CAM_ERR_INVALID_PARAM;
}
clip_width=rightbottom_x-lefttop_x+1;
clip_height=rightbottom_y-lefttop_y+1;
// Check clip area.
if((lefttop_x<0)||(lefttop_x>rightbottom_x)||
(lefttop_y<0)||(lefttop_y>rightbottom_y)||
(clip_width<0)||(clip_width>getWidth())||
(clip_height<0)||(clip_height>getHeight()))
{
return CAM_ERR_INVALID_PARAM;
}
// HW limitation check.
if(!check_hw_resize_param(clip_width, clip_height, width, height))
{
return CAM_ERR_INVALID_PARAM;
}
CamImage* tmp_img = new CamImage(V4L2_BUF_TYPE_VIDEO_CAPTURE, width, height, getPixFormat(), NULL);
if(tmp_img==NULL||!tmp_img->is_valid())
{
if(tmp_img!=NULL) delete tmp_img;
return CAM_ERR_NO_MEMORY;
}
tmp_img->setActualSize(tmp_img->img_buff->buf_size);
correct.x1 = lefttop_x;
correct.y1 = lefttop_y;
exact.x2 = rightbottom_x;
correct.y2 = rightbottom_y;
// Execute clip and resize.
intret = imageproc_clip_and_resize(getImgBuff(), getWidth(), getHeight(),
tmp_img->getImgBuff(), tmp_img->getWidth(), tmp_img->getHeight(), 16, &inrect);
if(ret!=0)
{
delete tmp_img;
return CAM_ERR_ILLEGAL_DEVERR;
}
// if the image has image buffer, delete it.
if(img.is_valid())
{
ImgBuff::delete_inst(img.img_buff);
}
// Set reserved image buffer into input parameter.
img.img_buff=tmp_img->img_buff;
img.img_buff->incRef();
tmp_img->img_buff=NULL;
delete tmp_img;
return CAM_ERR_SUCCESS;
}
If anyone knows about this matter, please let me know.
I am in charge of SPRESENSE support for Sony.
The clipping-only feature was supported in v2.0.2, which was recently released.
Please upgrade to v2.0.2 before attempting.
Thank you for your continued support on SPRESENSE.
SPRESENSE Support Team
© 2024 OneMinuteCode. All rights reserved.