87 for (; first != last; first += 2) {
88 string key((*first).toString());
89 const MxArray& val = *(first + 1);
92 else if (key ==
"FourCC") {
93 if (val.isChar() && val.numel()==4) {
94 string cc(val.toString());
95 fourcc = VideoWriter::fourcc(cc[0], cc[1], cc[2], cc[3]);
100 else if (key ==
"FPS")
101 fps = val.toDouble();
102 else if (key ==
"Color")
103 isColor = val.toBool();
106 "Unrecognized option %s", key.c_str());
125 for (; first != last; first += 2) {
126 string key((*first).toString());
127 const MxArray& val = *(first + 1);
128 if (key ==
"JpegQuality") {
133 else if (key ==
"JpegProgressive") {
138 else if (key ==
"JpegOptimize") {
143 else if (key ==
"JpegResetInterval") {
148 else if (key ==
"JpegLumaQuality") {
153 else if (key ==
"JpegChromaQuality") {
158 else if (key ==
"PngCompression") {
163 else if (key ==
"PngStrategy") {
168 else if (key ==
"PngBilevel") {
173 else if (key ==
"PxmBinary") {
178 else if (key ==
"ExrType") {
183 else if (key ==
"WebpQuality") {
188 else if (key ==
"PamTupleType") {
195 "Unrecognized option %s", key.c_str());
215 int id = rhs[0].toInt();
216 string method(rhs[1].toString());
219 if (method ==
"new") {
231 if (method ==
"delete") {
236 else if (method ==
"open") {
238 string filename(rhs[2].toString());
239 Size frameSize(rhs[3].toSize());
240 OptionsParser opts(rhs.
begin() + 4, rhs.
end());
241 bool b = obj->
open(filename, opts.apiPreference,
242 opts.fourcc, opts.fps, frameSize, opts.isColor);
245 else if (method ==
"isOpened") {
250 else if (method ==
"release") {
254 else if (method ==
"write") {
255 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
257 for (
int i=3; i<nrhs; i+=2) {
258 string key(rhs[i].toString());
259 if (key ==
"FlipChannels")
260 flip = rhs[i+1].toBool();
263 "Unrecognized option %s", key.
c_str());
270 else if (method ==
"get") {
272 int propId = (rhs[2].isChar()) ?
274 double value = obj->
get(propId);
277 else if (method ==
"set") {
279 int propId = (rhs[2].isChar()) ?
283 ImwriteOptionsParser opts(args.
begin(), args.
end());
284 nargchk((opts.params.size() % 2) == 0);
285 for (
size_t i = 0; i < opts.params.size(); i+=2) {
286 bool success = obj->
set(opts.params[i], opts.params[i+1]);
289 "Error setting property %d", opts.params[i]);
293 double value = rhs[3].toDouble();
294 bool success = obj->
set(propId, value);
297 "Error setting property %d", propId);
302 "Unrecognized operation %s", method.
c_str());
int fourcc
4-character code of codec used to compress the frames.
virtual bool isOpened() const
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0)
const ConstMap< string, int > PamFormatMap
PAM tuple types for option processing.
IMWRITE_PNG_STRATEGY_FILTERED
vector< int > params
vector of parameters as key/value pairs
const ConstMap< string, int > ExrTypeMap
EXR storage types for option processing.
LIBMWMEX_API_EXTERN_C void mexWarnMsgIdAndTxt(const char *identifier, const char *warn_msg,...)
Invoke a warning with message identifier 'identifier' and message derived from 'fmt' and subsequent a...
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
IMWRITE_PNG_STRATEGY_FIXED
virtual double get(int propId) const
IMWRITE_PAM_FORMAT_RGB_ALPHA
bool isColor
Flag to indicate whether to expect color or grayscale frames.
virtual void write(const Mat &image)
virtual bool open(const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true)
struct mxArray_tag mxArray
Forward declaration for mxArray.
double fps
Framerate of the created video stream.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Option arguments parser used by constructor and open method.
Option arguments parser for imwrite options used by set method.
IMWRITE_JPEG_RST_INTERVAL
VIDEOWRITER_PROP_FRAMEBYTES
const ConstMap< string, int > VidWriterProp
Capture Property map for option processing.
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
virtual bool set(int propId, double value)
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
int CV_FOURCC(char c1, char c2, char c3, char c4)
IMWRITE_JPEG_LUMA_QUALITY
IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA
const ConstMap< string, int > ApiPreferenceMap
API backends map for option processing.
int last_id
Last object id to allocate.
IMWRITE_PAM_FORMAT_GRAYSCALE
ImwriteOptionsParser(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Parse input arguments.
IMWRITE_PNG_STRATEGY_DEFAULT
Global constant definitions.
map< int, Ptr< VideoWriter > > obj_
Object container.
VIDEOWRITER_PROP_NSTRIPES
const ConstMap< string, int > PngStrategyMap
PNG encoding strategies for option processing.
OptionsParser(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Parse input arguments.
IMWRITE_PAM_FORMAT_BLACKANDWHITE
int apiPreference
API preference.
void flip(InputArray src, OutputArray dst, int flipCode)
std::map wrapper with one-line initialization and lookup method.
IMWRITE_JPEG_CHROMA_QUALITY