114 int id = rhs[0].toInt();
115 string method(rhs[1].toString());
118 if (method ==
"new") {
130 if (method ==
"delete") {
135 else if (method ==
"open") {
136 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
138 for (
int i=3; i<nrhs; i+=2) {
139 string key(rhs[i].toString());
144 "Unrecognized option %s", key.
c_str());
147 bool b = (rhs[2].isChar()) ?
148 obj->
open(rhs[2].toString(), pref) :
149 obj->
open(rhs[2].toInt() + pref);
152 else if (method ==
"isOpened") {
157 else if (method ==
"release") {
161 else if (method ==
"grab") {
163 bool b = obj->
grab();
166 else if (method ==
"retrieve") {
167 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
170 for (
int i=2; i<nrhs; i+=2) {
171 string key(rhs[i].toString());
172 if (key ==
"FlipChannels")
173 flip = rhs[i+1].toBool();
174 else if (key ==
"StreamIdx")
175 idx = rhs[i+1].toInt();
178 "Unrecognized option %s", key.
c_str());
186 else if (method ==
"read") {
187 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
189 for (
int i=2; i<nrhs; i+=2) {
190 string key(rhs[i].toString());
191 if (key ==
"FlipChannels")
192 flip = rhs[i+1].toBool();
195 "Unrecognized option %s", key.
c_str());
198 bool b = obj->
read(image);
203 else if (method ==
"get") {
205 int propId = (rhs[2].isChar()) ?
206 CapProp[rhs[2].toString()] : rhs[2].toInt();
207 double value = obj->
get(propId);
210 else if (method ==
"set") {
212 int propId = (rhs[2].isChar()) ?
213 CapProp[rhs[2].toString()] : rhs[2].toInt();
214 double value = rhs[3].toDouble();
215 bool success = obj->
set(propId, value);
218 "Error setting property %d", propId);
222 "Unrecognized operation %s", method.
c_str());
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0)
virtual bool open(const String &filename)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.
const ConstMap< string, int > CameraApiMap
Camera API map for option processing.
virtual bool read(OutputArray image)
struct mxArray_tag mxArray
Forward declaration for mxArray.
const ConstMap< string, int > CapProp
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...
int last_id
Last object id to allocate.
map< int, Ptr< VideoCapture > > obj_
Object container.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
virtual bool retrieve(OutputArray image, int flag=0)
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Global constant definitions.
virtual bool set(int propId, double value)
void flip(InputArray src, OutputArray dst, int flipCode)
std::map wrapper with one-line initialization and lookup method.
virtual double get(int propId) const
virtual bool isOpened() const