| | |
| | | }
|
| | | }
|
| | |
|
| | | int doFaceTrack(PL_SensetimeFaceTrack_Internal* in, |
| | | uint8_t* buffer, size_t width, size_t height, size_t stride, cv_pixel_format cvPixFmt)
|
| | | int doFaceTrack(PL_SensetimeFaceTrack_Internal* in, MB_Frame* frame)
|
| | | {
|
| | | //PipeLineElemTimingDebugger td(nullptr);
|
| | |
|
| | |
| | | if (in->frameCount % in->config.doTrackPerFrame != 0)
|
| | | return 0;
|
| | |
|
| | | //if (true)
|
| | | //{
|
| | | // struct timeval now;
|
| | | // gettimeofday(&now, nullptr);
|
| | | // const int fps = 20;
|
| | | // const int ft = 1000 / fps; // ms
|
| | | // if (now.tv_usec - frame->pts.tv_usec > 0.5 * ft * 1000)
|
| | | // return 0;
|
| | | //}
|
| | |
|
| | | //resize(bgr_frame, bgr_frame, Size(frame_width, frame_height), 0, 0, INTER_LINEAR);
|
| | |
|
| | | uint8_t* buffer = (uint8_t*)frame->buffer;
|
| | | const size_t width = frame->width;
|
| | | const size_t height = frame->height;
|
| | | const size_t stride = frame->width;
|
| | | cv_pixel_format cvPixFmt;
|
| | | if (frame->type == MB_Frame::MBFT_YUV420)
|
| | | cvPixFmt = CV_PIX_FMT_YUV420P;
|
| | | else if (frame->type == MB_Frame::MBFT_NV12)
|
| | | cvPixFmt = CV_PIX_FMT_NV12;
|
| | | else
|
| | | return -1;
|
| | |
|
| | | int face_count = 0;
|
| | | cv_result_t cv_result = CV_OK;
|
| | | cv_face_t* p_face = nullptr;
|
| | |
|
| | | //#test
|
| | | //cvPixFmt = CV_PIX_FMT_GRAY8;
|
| | |
|
| | | // realtime track
|
| | | cv_result = cv_face_track(in->handle_track, buffer, cvPixFmt,
|
| | | width, height, stride,
|
| | | CV_FACE_UP, &p_face, &face_count);
|
| | | cv_result = cv_face_track(in->handle_track, buffer, cvPixFmt, width, height, stride, CV_FACE_UP, &p_face, &face_count);
|
| | | if (cv_result != CV_OK)
|
| | | {
|
| | | LOG_ERROR << "cv_face_track failed, error : " << cv_result << LOG_ENDL;
|
| | |
| | |
|
| | | in->faceFeatures.clear();
|
| | | int face_count = 0;
|
| | | if (frame->type == MB_Frame::MBFT_YUV420)
|
| | | face_count = doFaceTrack(in, (uint8_t*)frame->buffer, frame->width, frame->height, frame->width, CV_PIX_FMT_YUV420P);
|
| | | else if (frame->type == MB_Frame::MBFT_NV12)
|
| | | face_count = doFaceTrack(in, (uint8_t*)frame->buffer, frame->width, frame->height, frame->width, CV_PIX_FMT_NV12);
|
| | | if (frame->type == MB_Frame::MBFT_YUV420 || frame->type == MB_Frame::MBFT_NV12)
|
| | | face_count = doFaceTrack(in, frame);
|
| | |
|
| | | if (face_count < 0)
|
| | | {
|