Skip to content

Commit

Permalink
Construct Mat from a low-level pointer or mat object
Browse files Browse the repository at this point in the history
  • Loading branch information
thqby committed Jun 7, 2022
1 parent 8e0df5d commit 5d09182
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions opencv_ahk/cv_mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ void Mat::Invoke(ResultToken& aResultToken, int aID, int aFlags, ExprTokenType*
}
new (&mC) cv::Mat(obj1, roi);
}
else if (aParamCount == 1) {
ExprTokenType t;
if (aParam[0]->symbol == SYM_VAR)
g_ahkapi->VarToToken(aParam[0]->var, t);
else t = *aParam[0];
if (t.symbol == SYM_INTEGER && (void*)t.value_int64 > (void*)65536) {
try {
mC = *(cv::Mat*)(t.value_int64);
}
catch (const std::exception&) {
aResultToken.result = g_ahkapi->Error(_T("invalid cv::Mat pointer"));
}
}
else if ((__result = TokenToVal(t, mC)) != CONDITION_TRUE)
_o_return_result;
}
else
aResultToken.result = g_ahkapi->Error(_T("invalid param count"));
return;
Expand Down Expand Up @@ -514,6 +530,22 @@ void UMat::Invoke(ResultToken& aResultToken, int aID, int aFlags, ExprTokenType*
}
new (&mC) cv::UMat(obj1, roi);
}
else if (aParamCount == 1) {
ExprTokenType t;
if (aParam[0]->symbol == SYM_VAR)
g_ahkapi->VarToToken(aParam[0]->var, t);
else t = *aParam[0];
if (t.symbol == SYM_INTEGER && (void*)t.value_int64 > (void*)65536) {
try {
mC = *(cv::UMat*)(t.value_int64);
}
catch (const std::exception&) {
aResultToken.result = g_ahkapi->Error(_T("invalid cv::UMat pointer"));
}
}
else if ((__result = TokenToVal(t, mC)) != CONDITION_TRUE)
_o_return_result;
}
else
aResultToken.result = g_ahkapi->Error(_T("invalid param count"));
return;
Expand Down

0 comments on commit 5d09182

Please sign in to comment.