OpenCV 4.5.0 on Pi 4 w/high-quality camera fails to stream

Hi All,

I’ve just installed OpenCV 4.5.0 on a Raspberry Pi 4B with a high-quality camera. When I attempt to write a simple app to view the camera’s output, I get these errors:

[ WARN:0] global /home/pi/opencv/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not read from resource.
[ WARN:0] global /home/pi/opencv/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/pi/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

The program is:

int main( int argc, char *argv[] )
{
	cv::Mat				m( 768, 1360, CV_8UC3, cv::Scalar( 0, 0, 0 ) ), b, cam;
	cv::VideoCapture	cap = cv::VideoCapture( "/dev/video0" );				//	camera stream

	int			i;
	char		buf[ 50 ];

	if ( !cap.isOpened( ) )
	{
		printf( "Can't open camera\n" );
		return( 1 );
	}

	printf( "Camera opened\n" );

//	cap.set( cv::CAP_PROP_FRAME_WIDTH, 480 );
//	cap.set( cv::CAP_PROP_FRAME_HEIGHT, 480 );

	printf( "Properties set\n" );

//	cv::line( b, cv::Point( 0, 0 ), cv::Point( 1359, 767 ), cv::Scalar( 0, 0, 255 ), 1, 8, 0 );
//	cv::namedWindow( "MRS", cv::WINDOW_NORMAL | cv::WINDOW_FULLSCREEN );
	cv::namedWindow( "CAM", cv::WINDOW_NORMAL );

	printf( "windows named\n" );

	for ( i = 1; cv::waitKey( 1 ) != 0x1B; i ++ )
	{
//		m.copyTo( b );
//		sprintf( buf, "%d", i );
//		cv::putText( b, buf, cv::Point( 500, 500 ), cv::FONT_HERSHEY_SIMPLEX, 10, cv::Scalar( 0, 255, 0 ) );
//		cv::imshow( "MRS", b );
//		cv::waitKey( 1 );
		cap.read( cam );
		printf( "camera read\n" );
		cv::imshow( "CAM", cam );
	}

	return( 0 );
}

If I change to the default video source cv::VideoCapture cap = cv::VideoCapture( 0 ) the Pi actually hangs and must be reset to recover.

Any thoughts most appreciated.

Thanks,
Scott