|  | 
 
| 使用下面代码识别人脸,出现内存泄漏,能否帮忙看看是哪里存在问题?
 
 int face_t::recognize(const cv::Mat& frame, std::vector<face_result_t>& faces)
 {
 faces.clear();
 
 // read image
 rockx_image_t input_image;
 input_image.data = (uchar*)frame.ptr<uchar>();
 input_image.pixel_format = ROCKX_PIXEL_FORMAT_BGR888;
 input_image.width = frame.cols;
 input_image.height = frame.rows;
 
 rockx_ret_t ret;
 
 /*************** FACE Detect ***************/
 // create rockx_face_array_t for store result
 rockx_object_array_t face_array;
 memset(&face_array, 0, sizeof(rockx_object_array_t));
 
 // detect face
 ret = rockx_face_detect(m_face_det_handle, &input_image, &face_array, nullptr);
 if (ret != ROCKX_RET_SUCCESS)
 {
 printf("rockx_face_detect error %d\n", ret);
 return -1;
 }
 
 /*************** FACE Landmark ***************/
 rockx_image_t out_img;
 out_img.width = 112;
 out_img.height = 112;
 out_img.pixel_format = ROCKX_PIXEL_FORMAT_BGR888;
 out_img.data = (uint8_t*)malloc(112 * 112 * 3 * sizeof(char));
 
 for (int i = 0; i < face_array.count; i++)
 {
 rockx_object_t* pO = &face_array.object[i];
 rockx_rect_t *pB = &pO->box;
 face_result face_result;
 face_result.confidence = pO->score;
 face_result.rect = cv::Rect(pB->left, pB->top, pB->right - pB->left, pB->bottom - pB->top);
 rockx_face_align(m_face_5landmarks_handle, &input_image, &pO->box, nullptr, &out_img);
 rockx_face_recognize(m_face_recognize_handle, &out_img, &face_result.feature);
 faces.push_back(face_result);
 }
 
 rockx_image_release(&out_img);//free(out_img.data);
 
 return 0;
 }
 
 
 | 
 |