本文整理汇总了C++中cv::InputArray类的典型用法代码示例。如果您正苦于以下问题:C++ InputArray类的具体用法?C++ InputArray怎么用?C++ InputArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InputArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transform
static bool transform(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _lut,
const int tilesX, const int tilesY, const cv::Size & tileSize)
{
cv::ocl::Kernel k("transform", cv::ocl::imgproc::clahe_oclsrc);
if(k.empty())
return false;
int tile_size[2];
tile_size[0] = tileSize.width;
tile_size[1] = tileSize.height;
cv::UMat src = _src.getUMat();
_dst.create(src.size(), src.type());
cv::UMat dst = _dst.getUMat();
cv::UMat lut = _lut.getUMat();
size_t localThreads[3] = { 32, 8, 1 };
size_t globalThreads[3] = { src.cols, src.rows, 1 };
int idx = 0;
idx = k.set(idx, cv::ocl::KernelArg::ReadOnlyNoSize(src));
idx = k.set(idx, cv::ocl::KernelArg::WriteOnlyNoSize(dst));
idx = k.set(idx, cv::ocl::KernelArg::ReadOnlyNoSize(lut));
idx = k.set(idx, src.cols);
idx = k.set(idx, src.rows);
idx = k.set(idx, tile_size);
idx = k.set(idx, tilesX);
k.set(idx, tilesY);
return k.run(2, globalThreads, localThreads, false);
}
示例2: d
inline void bs::pattern::shiftPattern(cv::InputArray src, cv::OutputArray dst, const int direction, const int shift)
{
cv::Mat d;
cv::copyMakeBorder(src, d, shift, shift, shift, shift, cv::BORDER_WRAP);
const auto direc = static_cast<Direction>(direction);
switch (direc)
{
default:
break;
case Top:
d = d(cv::Rect(cv::Point(shift, 2 * shift), src.size()));
break;
case Bottom:
d = d(cv::Rect(cv::Point(shift, 0), src.size()));
break;
case Left:
d = d(cv::Rect(cv::Point(2 * shift, shift), src.size()));
break;
case Right:
d = d(cv::Rect(cv::Point(0, shift), src.size()));
break;
}
d.copyTo(dst);
return;
}
示例3:
FilterCall::FilterCall(cv::InputArray in, cv::InputArray out,
impl::CallMetaData data, QString type,
QString description, QString requestedView)
: Call{ data, std::move(type),
std::move(description), std::move(requestedView) },
input_{ in.getMat().clone() }, output_{ out.getMat().clone() }
{
}
示例4: sadTemplate
void sadTemplate(cv::InputArray tar, cv::InputArray tmp, cv::OutputArray res, int *minx, int *miny){
//引数の入力をMatとして受け取る
cv::Mat tarM = tar.getMat();
cv::Mat tmpM = tmp.getMat();
cv::Mat resM = res.getMat();
//sadが最小値のところがマッチングしたい箇所なので
int minsad = std::numeric_limits<int>::max();
int sad = 0; //各回のsadを格納
int diff; //sadに加算する前の作業変数
int tarx,tary; //目的のxy座標
for(int y=0;y<tarM.rows - tmpM.rows;y++){
for(int x=0;x<tarM.cols - tmpM.cols;x++){
sad = 0; //次の領域の計算の前に初期化
//探索
for(int yt = 0; yt < tmpM.rows; yt++){
for(int xt = 0; xt < tmpM.cols; xt++){
diff = (int)(tarM.at<uchar>(y+yt,x+xt) - tmpM.at<uchar>(yt,xt));
if(diff < 0){ //負なら正に変換
diff = -diff;
}
sad += diff;
////残差逐次検定法
if(sad > minsad){
yt = tmpM.rows;
break;
}
}
}
//探索結果:sadが今までで最小なら
if(sad < minsad){
minsad = sad; //最小値を更新
//目的のxyを格納
tarx = x;
tary = y;
}
}
}
//outputに出力
for(int y=0;y<resM.rows;y++){
for(int x=0;x<resM.cols;x++){
if(x==tarx && y==tary){
resM.at<uchar>(y,x) = (uchar)0;
}else{
resM.at<uchar>(y,x) = (uchar)255;
}
}
}
std::cout << "最小値=" << minsad << std::endl;
std::cout << "最小点=[" << tarx << ", " << tary << "]" << std::endl;
*minx = tarx;
*miny = tary;
}
示例5: warmify
void warmify(cv::InputArray src, cv::OutputArray dst, uchar delta)
{
CV_Assert(src.type() == CV_8UC3);
Mat imgSrc = src.getMat();
CV_Assert(imgSrc.data);
dst.create(src.size(), CV_8UC3);
Mat imgDst = dst.getMat();
imgDst = imgSrc + Scalar(0, delta, delta);
}
示例6: stereoMatching
void stereo::stereoMatching(cv::InputArray _recImage1, cv::InputArray _recIamge2, cv::OutputArray _disparityMap, int minDisparity, int numDisparities, int SADWindowSize, int P1, int P2)
{
Mat img1 = _recImage1.getMat();
Mat img2 = _recIamge2.getMat();
_disparityMap.create(img1.size(), CV_16S);
Mat dis = _disparityMap.getMat();
StereoSGBM matcher(minDisparity, numDisparities, SADWindowSize, P1, P2);
matcher(img1, img2, dis);
dis = dis / 16.0;
}
示例7: testFunction
void testFunction(cv::InputArray ip, cv::InputArray op) {
cv::Mat img = ip.getMat();
cv::Mat obj = op.getMat();
printMatrix(img);
printMatrix(obj);
// std::cerr<<img.checkVector()<<std::endl;
}
示例8: stereoRectify
void stereo::stereoRectify(cv::InputArray _K1, cv::InputArray _K2, cv::InputArray _R, cv::InputArray _T,
cv::OutputArray _R1, cv::OutputArray _R2, cv::OutputArray _P1, cv::OutputArray _P2)
{
Mat K1 = _K1.getMat(), K2 = _K2.getMat(), R = _R.getMat(), T = _T.getMat();
_R1.create(3, 3, CV_32F);
_R2.create(3, 3, CV_32F);
Mat R1 = _R1.getMat();
Mat R2 = _R2.getMat();
_P1.create(3, 4, CV_32F);
_P2.create(3, 4, CV_32F);
Mat P1 = _P1.getMat();
Mat P2 = _P2.getMat();
if(K1.type()!=CV_32F)
K1.convertTo(K1,CV_32F);
if(K2.type()!=CV_32F)
K2.convertTo(K2,CV_32F);
if(R.type()!=CV_32F)
R.convertTo(R,CV_32F);
if(T.type()!=CV_32F)
T.convertTo(T,CV_32F);
if(T.rows != 3)
T = T.t();
// R and T is the transformation from the first to the second camera
// Get the transformation from the second to the first camera
Mat R_inv = R.t();
Mat T_inv = -R.t()*T;
Mat e1, e2, e3;
e1 = T_inv.t() / norm(T_inv);
/*Mat z = (Mat_<float>(1, 3) << 0.0,0.0,-1.0);
e2 = e1.cross(z);
e2 = e2 / norm(e2);*/
e2 = (Mat_<float>(1,3) << T_inv.at<float>(1)*-1, T_inv.at<float>(0), 0.0 );
e2 = e2 / (sqrt(e2.at<float>(0)*e2.at<float>(0) + e2.at<float>(1)*e2.at<float>(1)));
e3 = e1.cross(e2);
e3 = e3 / norm(e3);
e1.copyTo(R1.row(0));
e2.copyTo(R1.row(1));
e3.copyTo(R1.row(2));
R2 = R_inv * R1;
P1.setTo(Scalar(0));
R1.copyTo(P1.colRange(0, 3));
P1 = K1 * P1;
P2.setTo(Scalar(0));
R2.copyTo(P2.colRange(0, 3));
P2 = K2 * P2;
}
示例9: SLICSegment2Vector3D_
void SLICSegment2Vector3D_(cv::InputArray segment, cv::InputArray signal, double invalidValue, std::vector<std::vector<cv::Point3_<S>>>& segmentPoint)
{
double minv, maxv;
minMaxLoc(segment, &minv, &maxv);
segmentPoint.clear();
segmentPoint.resize((int)maxv + 1);
if (signal.depth() == CV_8U) _SLICSegment2Vector3D_<uchar, S>(segment, signal, (uchar)invalidValue, segmentPoint);
else if (signal.depth() == CV_16S) _SLICSegment2Vector3D_<short, S>(segment, signal, (short)invalidValue, segmentPoint);
else if (signal.depth() == CV_16U) _SLICSegment2Vector3D_<ushort, S>(segment, signal, (ushort)invalidValue, segmentPoint);
else if (signal.depth() == CV_32S) _SLICSegment2Vector3D_<int, S>(segment, signal, (int)invalidValue, segmentPoint);
else if (signal.depth() == CV_32F) _SLICSegment2Vector3D_<float, S>(segment, signal, (float)invalidValue, segmentPoint);
else if (signal.depth() == CV_64F) _SLICSegment2Vector3D_<double, S>(segment, signal, (double)invalidValue, segmentPoint);
}
示例10: estimate_rigid_transform
cv::Mat flutter::estimate_rigid_transform(cv::InputArray src1, cv::InputArray src2,
double ransac_good_ratio, double ransac_threshold)
{
Mat M(2, 3, CV_64F), A = src1.getMat(), B = src2.getMat();
CvMat matA = A, matB = B, matM = M;
int err = estimate_rigid_transform_detail(&matA, &matB, &matM,
ransac_good_ratio, ransac_threshold);
if (err == 1) {
return M;
} else {
return Mat();
}
}
示例11: StereoMatching
void StereoMatch::StereoMatching(cv::InputArray rec_image1, cv::InputArray rec_image2,
cv::OutputArray disparity_map, int min_disparity, int num_disparities, int SAD_window_size,
int P1, int P2)
{
cv::Mat img1 = rec_image1.getMat();
cv::Mat img2 = rec_image2.getMat();
disparity_map.create(img1.size(), CV_16S);
cv::Mat dis = disparity_map.getMat();
cv::StereoSGBM matcher(min_disparity, num_disparities, SAD_window_size, P1, P2);
matcher(img1, img2, dis);
dis = dis / 16.0;
}
示例12: check_transform_quality
void CV_HomographyTest::check_transform_quality(cv::InputArray src_points, cv::InputArray dst_points, const cv::Mat& H, const int norm_type)
{
Mat src, dst_original;
cv::transpose(src_points.getMat(), src); cv::transpose(dst_points.getMat(), dst_original);
cv::Mat src_3d(src.rows+1, src.cols, CV_32FC1);
src_3d(Rect(0, 0, src.rows, src.cols)) = src;
src_3d(Rect(src.rows, 0, 1, src.cols)) = Mat(1, src.cols, CV_32FC1, Scalar(1.0f));
cv::Mat dst_found, dst_found_3d;
cv::multiply(H, src_3d, dst_found_3d);
dst_found = dst_found_3d/dst_found_3d.row(dst_found_3d.rows-1);
double reprojection_error = cv::norm(dst_original, dst_found, norm_type);
CV_Assert ( reprojection_error > max_diff );
}
示例13: write
void Regression::write(cv::InputArray array)
{
write() << "kind" << array.kind();
write() << "type" << array.type();
if (isVector(array))
{
int total = (int)array.total();
int idx = regRNG.uniform(0, total);
write() << "len" << total;
write() << "idx" << idx;
cv::Mat m = array.getMat(idx);
if (m.total() * m.channels() < 26) //5x5 or smaller
write() << "val" << m;
else
write(m);
}
else
{
if (array.total() * array.channels() < 26) //5x5 or smaller
write() << "val" << array.getMat();
else
write(array.getMat());
}
}
示例14: calculate
FeatureValue FeatureShiCorner::calculate( cv::InputArray image )
{
Mat image_gray;
cvtColor( image, image_gray, CV_BGR2GRAY );
Mat corner( image.rows(), image.cols(), CV_32SC1, Scalar( 0 ) );
computeRawCornerMat( image_gray, corner );
auto points = genPoints( corner );
// return genDescriptor;
return FeatureValue();
}
示例15: ReduceRowByMost
void Tools::ReduceRowByMost(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _mask) {
cv::Mat src = _src.getMat();
_dst.create(1, src.cols, CV_8UC1);
cv::Mat dst = _dst.getMat();
cv::Mat mask = _mask.getMat();
if (src.depth() != CV_8U || mask.depth() != CV_8U) {
throw "TYPE DON'T SUPPORT";
}
int i, j, addr;
cv::Size size = src.size();
uchar *srcd = src.data;
uchar *dstd = dst.data;
uchar *maskd = mask.data;
std::map<uchar, int> m;
std::map<uchar, int>::iterator p;
uchar mostVal;
uchar rVal;
int r;
for (i = 0;i < size.width;++i) {
m.clear();
mostVal = 0;
for (j = 0;j < size.height;++j) {
addr = j*size.width + i;
if (!maskd[addr])
continue;
for (r = -2;r <= 2;++r) {
rVal = (uchar)(((int)srcd[addr] + r) % 180);
if (m.find(rVal) != m.end()) {
m[rVal]++;
}
else {
m[rVal] = 1;
}
}
}
if (m.size() == 0) {
dstd[i] = 0;
continue;
}
mostVal = m.begin()->first;
for (p = m.begin();p != m.end();++p) {
if (p->second > m[mostVal]) {
mostVal = p->first;
}
}
dstd[i] = mostVal;
}
}