I have a Gstreamer bad-plugin work on version 1.16.3, opencv 4.2.0 and Ubuntu 20.04.
I must have to make it work on Debian 10. Gstreamer work perfectly on Debian but not with my plugin. The plugin make video-stabilization with this process in C++:
https://learnopencv.com/video-stabilization-using-point-feature-matching-in-opencv/
When I launch a simple pipeline : gst-launch-1.0 videotestsrc ! videoconvert ! cvvideostab ! videoconvert ! autovideosink
cvvideostab is my gstreamer element with the stabilization algorithm
The error is :
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-ytxPbe/opencv-3.2.0+dfsg/modules/imgproc/src/color.cpp, line 9748
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-ytxPbe/opencv-3.2.0+dfsg/modules/imgproc/src/color.cpp:9748: error: (-215) scn == 3 || scn == 4 in function cvtColor
Abandon
The error come from the cvtColor function :
gst_cv_video_stab_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
Mat img) //frame
{
static int i = 0;
GstCvVideoStab *filter = GST_CV_VIDEO_STAB (base);
static Mat currFrame = img.clone();
Mat nextFrame = img.clone();
// Point au centre de l'image pour définir si zoom, dezoom ou pas
Point2f center;
center.x = (currFrame.cols)/2;
center.y = (currFrame.rows)/2;
#if DEBUG_VIDEO
g_print("center X = %f \n", center.x);
g_print("center Y = %f \n", center.y);
#endif
static Video video = Video();
static UMat grayCurr;
static UMat grayNext;
cvtColor(currFrame, grayCurr, COLOR_BGR2GRAY); //COLOR_RGBA2GRAY
cvtColor(nextFrame, grayNext, COLOR_RGB2GRAY); //COLOR_RGBA2GRAY
...
}
The function work with a video frame store in img and loop on all of video frame to make stabilization.
I try to debug the frame content with img.channels() and img.type() function.
In ubuntu (work perfectly) i have type = 24 and channels = 4.
On debian (error) I have type=144 and channels = 19.
I think the frame is not similar on Gstreaer 1.16.3 and 1.14.4, but on debian gstreamer 1.16.3 is only with unstable package.
I don't know where come from the error, I think from Gstreamer because version is different and openCv version is similar. When I launch the python code with a mp4 video or a webcam I have a good result with the algorithm and opencv function work good
When I launch the pipeline with cvvideostab but without video processing, Gstreamer sucess to launch the pipeline and teh element is "transparente":
static GstFlowReturn
gst_cv_video_stab_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
Mat img) //frame
{
return GST_FLOW_OK;
}
Thank you !