mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 18:13:13 +08:00
Merge pull request #24142 from beanjoy:4.x
Modify the outputVideoFormat after changing the output format in MSMF backend #24142 After changing the output format, need to modify the outputVideoFormat, otherwise the outputVideoFormat is always CV_CAP_MODE_BGR, and an error will occur when converting the format in retrieveVideoFrame(), and will always enter "case CV_CAP_MODE_BGR:" process. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [ ] I agree to contribute to the project under Apache 2 License. - [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake Co-authored-by: 李龙 <lilong@sobey.com>
This commit is contained in:
parent
1ebea1e0f0
commit
d0de575aef
@ -1159,7 +1159,12 @@ bool CvCapture_MSMF::configureVideoOutput(MediaType newType, cv::uint32_t outFor
|
|||||||
{
|
{
|
||||||
initStream(dwVideoStreamIndex, nativeFormat);
|
initStream(dwVideoStreamIndex, nativeFormat);
|
||||||
}
|
}
|
||||||
return initStream(dwVideoStreamIndex, newFormat);
|
if (!initStream(dwVideoStreamIndex, newFormat))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
outputVideoFormat = outFormat;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvCapture_MSMF::configureOutput()
|
bool CvCapture_MSMF::configureOutput()
|
||||||
|
@ -119,6 +119,21 @@ TEST(DISABLED_videoio_camera, v4l_read_mjpg)
|
|||||||
capture.release();
|
capture.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DISABLED_videoio_camera, msmf_read_yuyv)
|
||||||
|
{
|
||||||
|
VideoCapture capture(CAP_MSMF);
|
||||||
|
ASSERT_TRUE(capture.isOpened());
|
||||||
|
ASSERT_TRUE(capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('Y', 'U', 'Y', 'V')));
|
||||||
|
std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
|
||||||
|
std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
|
||||||
|
std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
|
||||||
|
std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
|
||||||
|
int fourcc = (int)capture.get(CAP_PROP_FOURCC);
|
||||||
|
std::cout << "FOURCC code: " << cv::format("0x%8x", fourcc) << std::endl;
|
||||||
|
test_readFrames(capture);
|
||||||
|
capture.release();
|
||||||
|
}
|
||||||
|
|
||||||
TEST(DISABLED_videoio_camera, v4l_open_mjpg)
|
TEST(DISABLED_videoio_camera, v4l_open_mjpg)
|
||||||
{
|
{
|
||||||
VideoCapture capture;
|
VideoCapture capture;
|
||||||
|
Loading…
Reference in New Issue
Block a user