mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 01:47:12 +08:00
Merge pull request #26601 from dai-xin:4.x
VideoCapture open camera slow
This commit is contained in:
commit
4a4031dc48
@ -3360,7 +3360,7 @@ namespace cv
|
||||
{
|
||||
videoInput VideoCapture_DShow::g_VI;
|
||||
|
||||
VideoCapture_DShow::VideoCapture_DShow(int index)
|
||||
VideoCapture_DShow::VideoCapture_DShow(int index, const VideoCaptureParameters& params)
|
||||
: m_index(-1)
|
||||
, m_width(-1)
|
||||
, m_height(-1)
|
||||
@ -3370,6 +3370,16 @@ VideoCapture_DShow::VideoCapture_DShow(int index)
|
||||
, m_convertRGBSet(true)
|
||||
{
|
||||
CoInitialize(0);
|
||||
|
||||
if (!params.empty()) {
|
||||
int tmpW = params.get<int>(CV_CAP_PROP_FRAME_WIDTH, -1);
|
||||
int tmpH = params.get<int>(CV_CAP_PROP_FRAME_HEIGHT, -1);
|
||||
int tmpFOURCC = params.get<int>(CV_CAP_PROP_FOURCC, -1);
|
||||
if (tmpW != -1 && tmpH != -1) {
|
||||
g_VI.setupDeviceFourcc(index, tmpW, tmpH, tmpFOURCC);
|
||||
}
|
||||
}
|
||||
|
||||
open(index);
|
||||
}
|
||||
VideoCapture_DShow::~VideoCapture_DShow()
|
||||
@ -3675,9 +3685,9 @@ void VideoCapture_DShow::close()
|
||||
m_convertRGBSet = true;
|
||||
}
|
||||
|
||||
Ptr<IVideoCapture> create_DShow_capture(int index)
|
||||
Ptr<IVideoCapture> create_DShow_capture(int index, const VideoCaptureParameters& params)
|
||||
{
|
||||
return makePtr<VideoCapture_DShow>(index);
|
||||
return makePtr<VideoCapture_DShow>(index, params);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace cv
|
||||
class VideoCapture_DShow : public IVideoCapture
|
||||
{
|
||||
public:
|
||||
VideoCapture_DShow(int index);
|
||||
VideoCapture_DShow(int index, const VideoCaptureParameters& params);
|
||||
virtual ~VideoCapture_DShow();
|
||||
|
||||
virtual double getProperty(int propIdx) const CV_OVERRIDE;
|
||||
|
@ -358,7 +358,7 @@ Ptr<IVideoWriter> cvCreateVideoWriter_MSMF(const std::string& filename, int four
|
||||
double fps, const Size& frameSize,
|
||||
const VideoWriterParameters& params);
|
||||
|
||||
Ptr<IVideoCapture> create_DShow_capture(int index);
|
||||
Ptr<IVideoCapture> create_DShow_capture(int index, const VideoCaptureParameters& params);
|
||||
|
||||
Ptr<IVideoCapture> create_V4L_capture_cam(int index);
|
||||
Ptr<IVideoCapture> create_V4L_capture_file(const std::string &filename);
|
||||
|
Loading…
Reference in New Issue
Block a user