mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #28844 from 0lekW:videoio-image-seq-start
Add CAP_PROP_IMAGE_SEQ_START #28844 Resolves https://github.com/opencv/opencv/issues/28843 New CAP_PROP_IMAGE_SEQ_START as an open only property for setting the first frame index when a VideoCap is opening with pattern, squashes test_images TODO. `CAP_FFMPEG`: forwarded to the image2 demuxers "start_number" option. `CAP_IMAGES`: Now a WithParams variant so the value reaches open() before probe runs, replaces 0 or 1 auto probe for sequence start. Property is opt in so default behavior is not affected. Please note that G_STREAMER is not considered here as I think its out of scope, it already has a "start-index" property and its backend is driven by the pipeline strings rather then these printf patterns. If an alternative solution is preferred that will not involve a new property or promoting CAP_IMAGES to a "WithParams" variant I don't mind implementing. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] 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
This commit is contained in:
@@ -624,6 +624,7 @@ struct CvCapture_FFMPEG
|
||||
int use_opencl;
|
||||
int extraDataIdx;
|
||||
int requestedThreads;
|
||||
int image_seq_start; // image2 demuxer start_number; -1 means unset
|
||||
};
|
||||
|
||||
void CvCapture_FFMPEG::init()
|
||||
@@ -679,6 +680,7 @@ void CvCapture_FFMPEG::init()
|
||||
use_opencl = 0;
|
||||
extraDataIdx = 1;
|
||||
requestedThreads = cv::getNumberOfCPUs();
|
||||
image_seq_start = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1160,6 +1162,10 @@ bool CvCapture_FFMPEG::open(const char* _filename, int index, const Ptr<IStreamR
|
||||
{
|
||||
nThreads = requestedThreads = params.get<int>(CAP_PROP_N_THREADS);
|
||||
}
|
||||
if (params.has(CAP_PROP_IMAGE_SEQ_START))
|
||||
{
|
||||
image_seq_start = params.get<int>(CAP_PROP_IMAGE_SEQ_START);
|
||||
}
|
||||
if (params.warnUnusedParameters())
|
||||
{
|
||||
CV_LOG_ERROR(NULL, "VIDEOIO/FFMPEG: unsupported parameters in .open(), see logger INFO channel for details. Bailout");
|
||||
@@ -1194,6 +1200,10 @@ bool CvCapture_FFMPEG::open(const char* _filename, int index, const Ptr<IStreamR
|
||||
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
|
||||
#endif
|
||||
}
|
||||
if (image_seq_start >= 0)
|
||||
{
|
||||
av_dict_set_int(&dict, "start_number", image_seq_start, 0);
|
||||
}
|
||||
CV_FFMPEG_FMT_CONST AVInputFormat* input_format = NULL;
|
||||
AVDictionaryEntry* entry = av_dict_get(dict, "input_format", NULL, 0);
|
||||
if (entry != 0)
|
||||
|
||||
Reference in New Issue
Block a user