46 if (alg ==
"AverageHash") {
50 else if (alg ==
"BlockMeanHash") {
53 for (; first != last; first += 2) {
54 string key(first->toString());
55 const MxArray& val = *(first + 1);
60 "Unrecognized option %s", key.c_str());
64 else if (alg ==
"ColorMomentHash") {
68 else if (alg ==
"MarrHildrethHash") {
72 for (; first != last; first += 2) {
73 string key(first->toString());
74 const MxArray& val = *(first + 1);
77 else if (key ==
"Scale")
78 scale = val.toFloat();
81 "Unrecognized option %s", key.c_str());
85 else if (alg ==
"PHash") {
89 else if (alg ==
"RadialVarianceHash") {
92 int numOfAngleLine = 180;
93 for (; first != last; first += 2) {
94 string key(first->toString());
95 const MxArray& val = *(first + 1);
98 else if (key ==
"NumOfAngleLine")
99 numOfAngleLine = val.toInt();
102 "Unrecognized option %s", key.c_str());
108 "Unrecognized hash algorithm %s",alg.
c_str());
129 int id = rhs[0].toInt();
130 string method(rhs[1].toString());
133 if (method ==
"new") {
136 rhs[2].toString(), rhs.
begin() + 3, rhs.
end());
142 else if (method ==
"averageHash") {
149 else if (method ==
"blockMeanHash") {
150 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
152 for (
int i=3; i<nrhs; i+=2) {
153 string key(rhs[i].toString());
158 "Unrecognized option %s", key.
c_str());
165 else if (method ==
"colorMomentHash") {
172 else if (method ==
"marrHildrethHash") {
173 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
176 for (
int i=3; i<nrhs; i+=2) {
177 string key(rhs[i].toString());
179 alpha = rhs[i+1].toFloat();
180 else if (key ==
"Scale")
181 scale = rhs[i+1].toFloat();
184 "Unrecognized option %s", key.
c_str());
191 else if (method ==
"pHash") {
198 else if (method ==
"radialVarianceHash") {
199 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
201 int numOfAngleLine = 180;
202 for (
int i=3; i<nrhs; i+=2) {
203 string key(rhs[i].toString());
205 sigma = rhs[i+1].toDouble();
206 else if (key ==
"NumOfAngleLine")
207 numOfAngleLine = rhs[i+1].toInt();
210 "Unrecognized option %s", key.
c_str());
222 if (method ==
"delete") {
227 else if (method ==
"typeid") {
229 plhs[0] =
MxArray(
string(
typeid(*obj).name()));
231 else if (method ==
"compute") {
237 else if (method ==
"compare") {
240 hashTwo(rhs[3].
toMat());
241 double val = obj->
compare(hashOne, hashTwo);
251 "Unrecognized operation %s",method.
c_str());
void blockMeanHash(cv::InputArray inputArr, cv::OutputArray outputArr, int mode=BLOCK_MEAN_HASH_MODE_0)
void averageHash(cv::InputArray inputArr, cv::OutputArray outputArr)
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
void colorMomentHash(cv::InputArray inputArr, cv::OutputArray outputArr)
const ConstMap< string, int > BlockMeanHashModeMap
BlockMeanHash mode map for option processing.
struct mxArray_tag mxArray
Forward declaration for mxArray.
double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
map< int, Ptr< ImgHashBase > > obj_
Object container.
void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
void radialVarianceHash(cv::InputArray inputArr, cv::OutputArray outputArr, double sigma=1, int numOfAngleLine=180)
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...
float toFloat() const
Convert MxArray to float.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
int last_id
Last object id to allocate.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
void marrHildrethHash(cv::InputArray inputArr, cv::OutputArray outputArr, float alpha=2.0f, float scale=1.0f)
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
double toDouble() const
Convert MxArray to double.
std::map wrapper with one-line initialization and lookup method.
Ptr< ImgHashBase > createImgHashBase(const string &alg, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ImgHashBase using options in arguments.
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
void pHash(cv::InputArray inputArr, cv::OutputArray outputArr)