zhouyuchong / face-recognition-deepstream

Deepstream app use retinaface and arcface for face recognition.
MIT License
55 stars 12 forks source link

OpenCV error at the end of the video #35

Open Athuliva opened 3 weeks ago

Athuliva commented 3 weeks ago

i get an opencv error at the end of a video.

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.2.0) ../modules/core/src/matmul.dispatch.cpp:349: error: (-215:Assertion failed) a_size.height == len in function 'gemm'

Aborted (core dumped)
zhouyuchong commented 3 weeks ago

@Athuliva sorry I didn't meet this problem so far. make sure all landmarks are correct, especially data format.

Athuliva commented 3 weeks ago

i am getting the error at the of the video. It reaches Aborted (core dumb) and no EOS signal.

zhouyuchong commented 3 weeks ago

@Athuliva no clue to this. Maybe you can use gdb to debug for more information.

Athuliva commented 2 weeks ago

i wasn't using the updated code for custom parser, and at some corner condition was getting wrong keypoints. with the updated custom parser everything works fine

Athuliva commented 2 weeks ago

i faced the same issue with the updated custom parser and retinaface-mobilenet. After debugging I found that the shape of dst matrix is not always (5,2)

 memcpy(dst.data, lmks, 2 * row * sizeof(float));

  //  DEBUG

   std::cout << "Matrix contents:" << dst.size()  << std::endl;
    for (int i = 0; i < dst.rows; i++) {
        for (int j = 0; j < dst.cols; j++) {
            std::cout << (int)dst.at<float>(i, j) << " ";
        }
        std::cout << std::endl;
    }

  // DEBUG END

  cv::Mat M = nvinfer->aligner.Align(dst, nvinfer->alignment_type);

i am getting the following output

Matrix contents:[2 x 5]
2 104 
18 102 
-2147483648 130 
14 152 
26 150 
0 debug-----
Matrix contents:[2 x 4]
0 104 
8 102 
-2147483648 130 
6 152 
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.2.0) ../modules/core/src/matmul.dispatch.cpp:349: error: (-215:Assertion failed) a_size.height == len in function 'gemm'

I hard coded int numNonZeroCount=10; instead of checking the number of non zero landmarks

 int numNonZeroCount=10;
  /*for (unsigned int i=0; i < ARRAYSIZE; i++) {
    if (landmarks[i]) numNonZeroCount++;
  }*/

  float lmks[numNonZeroCount/2][2];
  for (unsigned int i=0;i<numNonZeroCount;i++) {
    lmks[i/2][i%2] = landmarks[i];

@zhouyuchong but i am not sure commenting these few lines cause any side effects, can you please tell the purpose of checking the count of Non zero elements in the landmark

zhouyuchong commented 2 weeks ago

@Athuliva

For face alignment there should be 5 landmarks, which detector are you using?

to pass the landmarks from raw output of detector to obj_meta_data needs an extra step. It is ugly but I didn't find a better way so far. As you can see, the landmarks will first concat to label first, that's why they must be INT and NON-NEGATIVE. The number "-2147483648" in your output is abnormal, mostly caused by negative value. The definition here should be double/float better of course. But as I mentioned before, they will be trans into char later so INT is needed. check here do confirm they are all non-negative.

Athuliva commented 2 weeks ago

i am using retinaface from https://github.com/wang-xinyu/tensorrtx/tree/master/retinaface

zhouyuchong commented 2 weeks ago

@Athuliva doesn't matter with version you use, make sure all the landmarks are passed correctly.