本文整理汇总了C++中Mat::colRange方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::colRange方法的具体用法?C++ Mat::colRange怎么用?C++ Mat::colRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat::colRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeNeighborAdjust
void GaussSeidelSolver::computeNeighborAdjust(Mat heightMat, Mat& adjust) {
int numRow = heightMat.rows;
int numCol = heightMat.cols;
adjust = Mat::zeros(numRow, numCol, CV_32FC1);
Mat heightSubMat;
Mat adjustSubMat;
heightSubMat = heightMat.rowRange(1, numRow);
adjustSubMat = adjust.rowRange(0, numRow-1);
adjustSubMat += heightSubMat;
heightSubMat = heightMat.rowRange(0, numRow-1);
adjustSubMat = adjust.rowRange(1, numRow);
adjustSubMat += heightSubMat;
heightSubMat = heightMat.colRange(1, numCol);
adjustSubMat = adjust.colRange(0, numCol-1);
adjustSubMat += heightSubMat;
heightSubMat = heightMat.colRange(0, numCol-1);
adjustSubMat = adjust.colRange(1, numCol);
adjustSubMat += heightSubMat;
adjust /= 4.0;
}
示例2: image_jacobian_affine_ECC
static void image_jacobian_affine_ECC(const Mat& src1, const Mat& src2,
const Mat& src3, const Mat& src4,
Mat& dst)
{
CV_Assert(src1.size() == src2.size());
CV_Assert(src1.size() == src3.size());
CV_Assert(src1.size() == src4.size());
CV_Assert(src1.rows == dst.rows);
CV_Assert(dst.cols == (6*src1.cols));
CV_Assert(dst.type() == CV_32FC1);
const int w = src1.cols;
//compute Jacobian blocks (6 blocks)
dst.colRange(0,w) = src1.mul(src3);//1
dst.colRange(w,2*w) = src2.mul(src3);//2
dst.colRange(2*w,3*w) = src1.mul(src4);//3
dst.colRange(3*w,4*w) = src2.mul(src4);//4
src1.copyTo(dst.colRange(4*w,5*w));//5
src2.copyTo(dst.colRange(5*w,6*w));//6
}
示例3: SetBorder2Zero
void SetBorder2Zero(Mat &mat, int bW, int bH)
{
mat.rowRange(0, bH).setTo(0);
mat.rowRange(mat.rows - bH, mat.rows).setTo(0);
mat.colRange(0, bW).setTo(0);
mat.colRange(mat.cols - bW, mat.cols).setTo(0);
}
示例4: addToNewSamples
void NNClassifier::addToNewSamples(const Mat &patch, const int c)
{
const int newSamplesNum = 100;
Mat &samples = (c == CLASS_POS ? newSamplesP : newSamplesN);
int n = samples.cols / NN_PATCH_SIZE;
Mat tmp;
if(n > newSamplesNum)
{
tmp = Mat(NN_PATCH_SIZE, samples.cols, CV_8UC3);
samples.colRange(NN_PATCH_SIZE, samples.cols).copyTo(tmp.colRange(0, samples.cols - NN_PATCH_SIZE));
}
else
{
tmp = Mat(NN_PATCH_SIZE, samples.cols + NN_PATCH_SIZE, CV_8UC3);
if(samples.cols) samples.colRange(0, samples.cols).copyTo(tmp.colRange(0, samples.cols));
}
samples = tmp;
Mat _patch = patch.clone();
normalize(_patch, _patch, 0, 255, NORM_MINMAX);
_patch.convertTo(_patch, CV_8U);
cvtColor(_patch, samples.colRange(samples.cols - NN_PATCH_SIZE, samples.cols), CV_GRAY2BGR);
}
示例5: image_jacobian_euclidean_ECC
static void image_jacobian_euclidean_ECC(const Mat& src1, const Mat& src2,
const Mat& src3, const Mat& src4,
const Mat& src5, Mat& dst)
{
CV_Assert( src1.size()==src2.size());
CV_Assert( src1.size()==src3.size());
CV_Assert( src1.size()==src4.size());
CV_Assert( src1.rows == dst.rows);
CV_Assert(dst.cols == (src1.cols*3));
CV_Assert(dst.type() == CV_32FC1);
CV_Assert(src5.isContinuous());
const float* hptr = src5.ptr<float>(0);
const float h0 = hptr[0];//cos(theta)
const float h1 = hptr[3];//sin(theta)
const int w = src1.cols;
//create -sin(theta)*X -cos(theta)*Y for all points as a block -> hatX
Mat hatX = -(src3*h1) - (src4*h0);
//create cos(theta)*X -sin(theta)*Y for all points as a block -> hatY
Mat hatY = (src3*h0) - (src4*h1);
//compute Jacobian blocks (3 blocks)
dst.colRange(0, w) = (src1.mul(hatX))+(src2.mul(hatY));//1
src1.copyTo(dst.colRange(w, 2*w));//2
src2.copyTo(dst.colRange(2*w, 3*w));//3
}
示例6: d
//计算式中的d(a, b),点的距离的平方和
double d(Point2i i, Point2i xi, Mat line, bool which){
Mat m1 = line.colRange(Range(i.x - winr, i.x + winr)).rowRange(Range(i.y - winr, i.y + winr));
Mat m2 = line.colRange(Range(xi.x - winr, xi.x + winr)).rowRange(Range(xi.y - winr, xi.y + winr));
double dist = 0;
vector<Point2i> ml1, ml2;
for (int y = 0; y < m1.rows; y++)
for (int x = 0; x < m1.cols; x++){
if (m1.at<uchar>(y, x)){
ml1.push_back(Point2i(x, y));
}
}
for (int y = 0; y < m2.rows; y++)
for (int x = 0; x < m2.cols; x++){
if (m2.at<uchar>(y, x)){
ml2.push_back(Point2i(x, y));
}
}
for (int l1 = 0; l1 < ml1.size(); l1++){
double min = 1E20;
for (int l2 = 0; l2 < ml2.size(); l2++){
Point2i vec = ml1[l1] - ml2[l2];
double dd = (vec.x*vec.x + vec.y*vec.y);
if (dd < min) min = dd;
}
dist += min;
}
if (which) return dist / ml2.size();
else return dist / ml1.size();
}
示例7: run
void RGBLineChartThread::run()
{
Mat frame;
Mat b_hist,g_hist,r_hist;
std::vector<Mat> bgr_planes;
int histSize = 256;
float range[] = {0,256};
const float* histRange = {range};
bool uniform = true;
bool accumulate = false;
int hist_w = 512;
int hist_h = 400;
int bin_w = cvRound((double)hist_w / histSize);
Mat histImage(hist_h , hist_w , CV_8UC3 , Scalar(0,0,0));
Mat MergedImage;
if( !cap.isOpened() )
return;
while(true)
{
cap >> frame;
split(frame , bgr_planes);
histImage = Mat::zeros(hist_h , hist_w , CV_8UC3);
cv::calcHist(&bgr_planes[0],1,0,Mat(),b_hist,1,&histSize,&histRange,uniform,accumulate);
cv::calcHist(&bgr_planes[1],1,0,Mat(),g_hist,1,&histSize,&histRange,uniform,accumulate);
cv::calcHist(&bgr_planes[2],1,0,Mat(),r_hist,1,&histSize,&histRange,uniform,accumulate);
cv::normalize(b_hist,b_hist,0,histImage.rows,NORM_MINMAX,-1,Mat());
cv::normalize(g_hist,g_hist,0,histImage.rows,NORM_MINMAX,-1,Mat());
cv::normalize(r_hist,r_hist,0,histImage.rows,NORM_MINMAX,-1,Mat());
for(int i=1; i<histSize; i++)
{
cv::line(histImage,Point(bin_w*(i-1) , hist_h - cvRound(b_hist.at<float>(i - 1)) ),Point(bin_w*i , hist_h - cvRound(b_hist.at<float>(i)) ),Scalar(255,0,0),2,8,0);
cv::line(histImage,Point(bin_w*(i-1) , hist_h - cvRound(g_hist.at<float>(i - 1)) ),Point(bin_w*i , hist_h - cvRound(g_hist.at<float>(i))),Scalar(0,255,0),2,8,0);
cv::line(histImage,Point(bin_w*(i-1) , hist_h - cvRound(r_hist.at<float>(i - 1)) ),Point(bin_w*i , hist_h - cvRound(r_hist.at<float>(i))),Scalar(0,0,255),2,8,0);
}
merge(bgr_planes,frame);
resize(frame,frame,cv::Size(histImage.cols,histImage.rows));
int totalCols = histImage.cols + frame.cols;
MergedImage.create(histImage.rows, totalCols,histImage.type());
Mat subImage = MergedImage.colRange(0,histImage.cols);
histImage.copyTo(subImage);
subImage = MergedImage.colRange(histImage.cols , totalCols);
frame.copyTo(subImage);
emit NewLineChart(&MergedImage);
bgr_planes.clear();
waitKey(30);
}
return;
}
示例8: rect_accumulate_rect
void rect_accumulate_rect(CvRect r)
{
int x = r.x - area_x;
int y = r.y - area_y;
if (area_roi.dims > 0)
area.colRange(x,x+r.width).rowRange(y,y+r.height) |= area_roi.colRange(x,x+r.width).rowRange(y,y+r.height);
else
area.colRange(x,x+r.width).rowRange(y,y+r.height) = 1;
}
示例9: assembleArts
void assembleArts()
{
Mat edges;
Canny(grabbedImage,edges,50,150);
int x0,y0,x1,y1;
if (startRect.x>endRect.x)
{
x0=endRect.x;
x1=startRect.x;
}
else
{
x1=endRect.x;
x0=startRect.x;
}
if (startRect.y>endRect.y)
{
y0=endRect.y;
y1=startRect.y;
}
else
{
y1=endRect.y;
y0=startRect.y;
}
finalImage = Mat(Size((x1-x0)*3,y1-y0),CV_8UC3,Scalar(132,254,255));
Mat blurMan = finalImage.colRange(0,x1-x0);
Mat blackMan = finalImage.colRange(x1-x0,2*(x1-x0));
Mat greenMan = finalImage.colRange(2*(x1-x0),3*(x1-x0));
Mat edgeMask=edges(Rect(x0,y0,x1-x0,y1-y0)).clone();
edgeMask = (edgeMask == 255);
blackMan.setTo(Scalar(0,0,0),edgeMask);
Mat blur = blurMan.clone();
blur.setTo(Scalar(0,100,0),edgeMask);
addWeighted(blurMan,0.85,blur,0.15,0.0,blurMan);
GaussianBlur(blurMan,blurMan,Size(3,7),2,6);
Mat edgeMaskHalfFull = edgeMask.clone();
Mat edgeMaskToClear = edgeMaskHalfFull.rowRange(0,(int)(0.3*(y1-y0)));
edgeMaskToClear.setTo(Scalar(0));
greenMan.setTo(Scalar(0,255,0),edgeMaskHalfFull);
imshow("finalImage",finalImage);
}
示例10: LieToP
static void LieToP(InputArray Lie, OutputArray _P){
Mat p = Lie.getMat();
_P.create(4,4,p.type());
Mat P = _P.getMat();
if(p.cols==1){
p = p.t();
}
Mat R=rodrigues(p.colRange(Range(0,3)));
Mat T=p.colRange(Range(3,6)).t();
hconcat(R,T,P);
make4x4(P).copyTo(_P);
}
示例11: eyelidsDistances
void eyelidsDistances(Mat eyes, int * outputDL, int * outputDR, int leftMaximumOpened, int rightMaximumOpened)
{
Mat eyesGray;
cvtColor(eyes, eyesGray, CV_BGR2GRAY);
int m = eyesGray.rows;
int n = eyesGray.cols;
Mat leftEye = eyesGray.colRange(0, n / 2 - 11);
Mat rightEye = eyesGray.colRange(n / 2 + 10, n);
*outputDL = eyelidDistance(leftEye, leftMaximumOpened * 0.4);
*outputDR = eyelidDistance(rightEye, rightMaximumOpened * 0.4);
}
示例12: normalValidation
void normalValidation( DataSet& data, TrainResult& result)
{
//these vars not needed - use empty Mat
Mat varIdx, missingDataMask;
Mat sampleIdx;
result.train_hr = 0;
result.test_hr = 0;
result.fpRate = 0;
result.fnRate = 0;
// printf( "numSamples %d", data.numSamples);
//CvBoostTree boost;
//define test and trainingsset
float partTrain = 1.0/8.0;
sampleIdx = Mat(1,data.numSamples,CV_8U,1.0);
int negIdx = (int)floor(partTrain*data.numNeg);
sampleIdx.colRange(negIdx*5, negIdx*6) = 0.0;
int posIdx = (int)floor( partTrain*data.numPos );
sampleIdx.colRange( data.numNeg+posIdx*5, data.numNeg + posIdx*6) = 0.0;
//int numT = (cv::sum( sampleIdx ))[0];
//printf("sample Idx sum (trainsamples): %d\n",numT);
int numTestSamples = negIdx + posIdx;
printf("numSamples: %d -- numTrainSamples: %d -- numTestSamples: %d\n",data.numSamples, data.numSamples-numTestSamples, numTestSamples );
//training
forest.train(data.data, CV_ROW_SAMPLE, data.responses, varIdx, sampleIdx, data.varType, missingDataMask, forestParams);
//booster.train(data.data, CV_ROW_SAMPLE, data.responses, varIdx, sampleIdx, data.varType, missingDataMask, boostParams);
//evaluation
evaluation(forest, data, sampleIdx, result);
double sum = (cv::sum(result.var_importance))[0];
result.var_importance /= sum;
printf( "____\nRecognition rate: train = %.2f%%, test = %.2f%% -- overall FN = %.2f%%, FP = %.2f%%\n",
result.train_hr*100., result.test_hr*100. ,result.fnRate*100. ,result.fpRate*100.);
}
示例13: LieToRT
static void LieToRT(InputArray Lie, OutputArray _R, OutputArray _T){
Mat p = Lie.getMat();
_R.create(3,3,CV_64FC1);
Mat R = _R.getMat();
_T.create(3,1,CV_64FC1);
Mat T = _T.getMat();
if(p.cols==1){
p = p.t();
}
rodrigues(p.colRange(Range(0,3))).copyTo(R);
Mat(p.colRange(Range(3,6)).t()).copyTo(T);
}
示例14: image_jacobian_translation_ECC
static void image_jacobian_translation_ECC(const Mat& src1, const Mat& src2, Mat& dst)
{
CV_Assert( src1.size()==src2.size());
CV_Assert( src1.rows == dst.rows);
CV_Assert(dst.cols == (src1.cols*2));
CV_Assert(dst.type() == CV_32FC1);
const int w = src1.cols;
//compute Jacobian blocks (2 blocks)
src1.copyTo(dst.colRange(0, w));
src2.copyTo(dst.colRange(w, 2*w));
}
示例15: main
/** @function main */
int main( )
{
VideoCapture cap("./write3.mp4"); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
// time_t start,end;
for(k = 0;;k++)
{
auto t1 = chrono::high_resolution_clock::now();
cap >> src;
// src=src.colRange(120,600);
if(src.empty())
continue;
src=src.colRange(180,540);
// src=src.rowRange(100,300);
cvtColor( src, src_gray, CV_BGR2GRAY );
// blur( src_gray, src_gray, Size(3,3) );
/// Create Window
if(src.size().height==0||src.size().width==0)
continue;
regionSelect();
auto t2 = std::chrono::high_resolution_clock::now();
// cout<<" Time taken -"<<chrono::duration_cast<chrono::milliseconds>(t2-t1).count()<<endl;
// waitKey();
}
// waitKey(0);
return(0);
}