mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #7761 from UnaNancyOwen:add_props
This commit is contained in:
commit
b5b3a0474d
@ -556,6 +556,20 @@ enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, //!< Capture only preview fro
|
||||
|
||||
//! @} gPhoto2
|
||||
|
||||
|
||||
/** @name Images backend
|
||||
@{
|
||||
*/
|
||||
|
||||
/** @brief Images backend properties
|
||||
|
||||
*/
|
||||
enum { CAP_PROP_IMAGES_BASE = 18000,
|
||||
CAP_PROP_IMAGES_LAST = 19000 // excluding
|
||||
};
|
||||
|
||||
//! @} Images
|
||||
|
||||
//! @} videoio_flags_others
|
||||
|
||||
|
||||
|
@ -332,18 +332,23 @@ public:
|
||||
|
||||
virtual bool open( const char* _filename );
|
||||
virtual void close();
|
||||
virtual bool setProperty( int, double );
|
||||
virtual bool writeFrame( const IplImage* );
|
||||
|
||||
protected:
|
||||
char* filename;
|
||||
unsigned currentframe;
|
||||
std::vector<int> params;
|
||||
};
|
||||
|
||||
bool CvVideoWriter_Images::writeFrame( const IplImage* image )
|
||||
{
|
||||
char str[_MAX_PATH];
|
||||
sprintf(str, filename, currentframe);
|
||||
int ret = cvSaveImage(str, image);
|
||||
std::vector<int> image_params = params;
|
||||
image_params.push_back(0); // append parameters 'stop' mark
|
||||
image_params.push_back(0);
|
||||
int ret = cvSaveImage(str, image, &image_params[0]);
|
||||
|
||||
currentframe++;
|
||||
|
||||
@ -358,6 +363,7 @@ void CvVideoWriter_Images::close()
|
||||
filename = 0;
|
||||
}
|
||||
currentframe = 0;
|
||||
params.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -380,10 +386,23 @@ bool CvVideoWriter_Images::open( const char* _filename )
|
||||
}
|
||||
|
||||
currentframe = offset;
|
||||
params.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CvVideoWriter_Images::setProperty( int id, double value )
|
||||
{
|
||||
if (id >= cv::CAP_PROP_IMAGES_BASE && id < cv::CAP_PROP_IMAGES_LAST)
|
||||
{
|
||||
params.push_back( id - cv::CAP_PROP_IMAGES_BASE );
|
||||
params.push_back( static_cast<int>( value ) );
|
||||
return true;
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
|
||||
CvVideoWriter* cvCreateVideoWriter_Images( const char* filename )
|
||||
{
|
||||
CvVideoWriter_Images *writer = new CvVideoWriter_Images;
|
||||
|
Loading…
Reference in New Issue
Block a user