Exemplo n.º 1
0
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());
    }
}
void illuminationChange(cv::InputArray _src,
                        cv::InputArray _mask,
                        cv::OutputArray _dst,
                        float a,
                        float b)
{

    Mat src  = _src.getMat();
    Mat mask  = _mask.getMat();
    _dst.create(src.size(), src.type());
    Mat blend = _dst.getMat();
    float alpha = a;
    float beta = b;

    Mat gray = Mat::zeros(mask.size(), CV_8UC1);

    if(mask.channels() == 3)
        cvtColor(mask, gray, COLOR_BGR2GRAY);
    else
        gray = mask;

    Mat cs_mask = Mat::zeros(src.size(), CV_8UC3);

    src.copyTo(cs_mask, gray);

    Cloning obj;
    obj.illum_change(src, cs_mask, gray, blend, alpha, beta);

}
void stereo_disparity_normal(cv::InputArray left_image, cv::InputArray right_image, cv::OutputArray disp_, 
					  int max_dis_level, int scale, float sigma) {
	cv::Mat imL = left_image.getMat();
	cv::Mat imR = right_image.getMat();
	
	CV_Assert(imL.size() == imR.size());
	CV_Assert(imL.type() == CV_8UC3 && imR.type() == CV_8UC3);

	cv::Size imageSize = imL.size();

	disp_.create(imageSize, CV_8U);
	cv::Mat disp = disp_.getMat();
	
	CDisparityHelper dispHelper;
	
//step 1: cost initialization
	cv::Mat costVol = dispHelper.GetMatchingCost(imL, imR, max_dis_level);

//step 2: cost aggregation
	CSegmentTree stree;
	CColorWeight cWeight(imL);
	stree.BuildSegmentTree(imL.size(), sigma, TAU, cWeight);
	stree.Filter(costVol, max_dis_level);

//step 3: disparity computation
	cv::Mat disparity = dispHelper.GetDisparity_WTA((float*)costVol.data, 
		imageSize.width, imageSize.height, max_dis_level);

	MeanFilter(disparity, disparity, 3);

	disparity *= scale;
	disparity.copyTo(disp);
}
void colorChange(cv::InputArray _src,
                 cv::InputArray _mask,
                 cv::OutputArray _dst,
                 float r,
                 float g,
                 float b)
{
    Mat src  = _src.getMat();
    Mat mask  = _mask.getMat();
    _dst.create(src.size(), src.type());
    Mat blend = _dst.getMat();

    float red = r;
    float green = g;
    float blue = b;

    Mat gray = Mat::zeros(mask.size(), CV_8UC1);

    if(mask.channels() == 3)
        cvtColor(mask, gray, COLOR_BGR2GRAY);
    else
        gray = mask;

    Mat cs_mask = Mat::zeros(src.size(), CV_8UC3);

    src.copyTo(cs_mask, gray);

    Cloning obj;
    obj.local_color_change(src, cs_mask, gray, blend, red, green, blue);
}
void textureFlattening(cv::InputArray _src,
                       cv::InputArray _mask,
                       cv::OutputArray _dst,
                       double low_threshold,
                       double high_threshold,
                       int kernel_size)
{

    Mat src  = _src.getMat();
    Mat mask  = _mask.getMat();
    _dst.create(src.size(), src.type());
    Mat blend = _dst.getMat();

    Mat gray = Mat::zeros(mask.size(), CV_8UC1);

    if(mask.channels() == 3)
        cvtColor(mask, gray, COLOR_BGR2GRAY);
    else
        gray = mask;

    Mat cs_mask = Mat::zeros(src.size(), CV_8UC3);

    src.copyTo(cs_mask, gray);

    Cloning obj;
    obj.texture_flatten(src, cs_mask, gray, low_threshold, high_threshold, kernel_size, blend);
}
Exemplo n.º 6
0
void globalMatting(cv::InputArray _image, cv::InputArray _trimap, cv::OutputArray _foreground, cv::OutputArray _alpha, cv::OutputArray _conf)
{
    cv::Mat image = _image.getMat();
    cv::Mat trimap = _trimap.getMat();

    if (image.empty())
        CV_Error(CV_StsBadArg, "image is empty");
    if (image.type() != CV_8UC3)
        CV_Error(CV_StsBadArg, "image mush have CV_8UC3 type");

    if (trimap.empty())
        CV_Error(CV_StsBadArg, "trimap is empty");
    if (trimap.type() != CV_8UC1)
        CV_Error(CV_StsBadArg, "trimap mush have CV_8UC1 type");

    if (image.size() != trimap.size())
        CV_Error(CV_StsBadArg, "image and trimap mush have same size");

    cv::Mat &foreground = _foreground.getMatRef();
    cv::Mat &alpha = _alpha.getMatRef();
    cv::Mat tempConf;

    globalMattingHelper(image, trimap, foreground, alpha, tempConf);

    if(_conf.needed())
        tempConf.copyTo(_conf);
}
Exemplo n.º 7
0
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() }
{
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
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;

}
Exemplo n.º 11
0
Arquivo: ippe.cpp Projeto: lz89/IPPE
void IPPE::PoseSolver::solveGeneric(cv::InputArray _objectPoints, cv::InputArray _normalizedInputPoints,
                                    cv::OutputArray _Ma, cv::OutputArray _Mb)
{

    //argument checking:
    size_t n = _objectPoints.rows() * _objectPoints.cols(); //number of points
    int objType = _objectPoints.type();
    int type_input = _normalizedInputPoints.type();
    assert((objType == CV_32FC3) | (objType == CV_64FC3));
    assert((type_input == CV_32FC2) | (type_input == CV_64FC2));
    assert((_objectPoints.rows() == 1) | (_objectPoints.cols() == 1));
    assert((_objectPoints.rows() >= 4) | (_objectPoints.cols() >= 4));
    assert((_normalizedInputPoints.rows() == 1) | (_normalizedInputPoints.cols() == 1));
    assert(static_cast<size_t>(_objectPoints.rows() * _objectPoints.cols()) == n);

    cv::Mat normalizedInputPoints;
    if (type_input == CV_32FC2) {
        _normalizedInputPoints.getMat().convertTo(normalizedInputPoints, CV_64FC2);
    }
    else {
        normalizedInputPoints = _normalizedInputPoints.getMat();
    }

    cv::Mat objectInputPoints;
    if (type_input == CV_32FC3) {
        _objectPoints.getMat().convertTo(objectInputPoints, CV_64FC3);
    }
    else {
        objectInputPoints = _objectPoints.getMat();
    }

    cv::Mat canonicalObjPoints;
    cv::Mat MmodelPoints2Canonical;

    //transform object points to the canonical position (zero centred and on the plane z=0):
    makeCanonicalObjectPoints(objectInputPoints, canonicalObjPoints, MmodelPoints2Canonical);

    //compute the homography mapping the model's points to normalizedInputPoints
    cv::Mat H;
    HomographyHO::homographyHO(canonicalObjPoints, _normalizedInputPoints, H);

    //now solve
    cv::Mat MaCanon, MbCanon;
    solveCanonicalForm(canonicalObjPoints, normalizedInputPoints, H, MaCanon, MbCanon);

    //transform computed poses to account for canonical transform:
    cv::Mat Ma = MaCanon * MmodelPoints2Canonical;
    cv::Mat Mb = MbCanon * MmodelPoints2Canonical;

    //output poses:
    Ma.copyTo(_Ma);
    Mb.copyTo(_Mb);
}
Exemplo n.º 12
0
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;

}
Exemplo n.º 13
0
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();
	}
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const
{
    // only color images are supperted
    cv::Mat image = _image.getMat();
    CV_Assert(image.type() == CV_8UC3);

    Fields& fld = *fields;
    fld.calcLevels(image.size(),(float) minScale, (float)maxScale, scales);

    objects.clear();

    if (_rois.empty())
        return detectNoRoi(image, objects);

    int shr = fld.shrinkage;

    cv::Mat roi = _rois.getMat();
    cv::Mat mask(image.rows / shr, image.cols / shr, CV_8UC1);

    mask.setTo(cv::Scalar::all(0));
    cv::Rect* r = roi.ptr<cv::Rect>(0);
    for (int i = 0; i < (int)roi.cols; ++i)
        cv::Mat(mask, cv::Rect(r[i].x / shr, r[i].y / shr, r[i].width / shr , r[i].height / shr)).setTo(cv::Scalar::all(1));

    // create integrals
    ChannelStorage storage(image, shr);

    typedef std::vector<Level>::const_iterator lIt;
    for (lIt it = fld.levels.begin(); it != fld.levels.end(); ++it)
    {
         const Level& level = *it;

        // we train only 3 scales.
        if (level.origScale > 2.5) break;

         for (int dy = 0; dy < level.workRect.height; ++dy)
         {
             uchar* m  = mask.ptr<uchar>(dy);
             for (int dx = 0; dx < level.workRect.width; ++dx)
             {
                 if (m[dx])
                 {
                     storage.offset = dy * storage.step + dx;
                     fld.detectAt(dx, dy, level, storage, objects);
                 }
             }
         }
    }

    if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
}
Exemplo n.º 16
0
void Picture::setAnimation(const AnimationEnum &animationEnum, 
	const cv::InputArray &startImg, const cv::InputArray &endImg)
{
	delete animation;

	Mat startImage = startImg.getMat();
	Mat endImage = endImg.getMat();
	if (!startImg.empty() && startImg.size() != this->size())
		cv::resize(startImg, startImage, this->size());
	if (!endImg.empty() && endImg.size() != this->size())
		cv::resize(endImg, endImage, this->size());
	
	animation = AnimationFactory::createAnimation(animationEnum, startImage, endImage);
}
Exemplo n.º 17
0
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 );
}
Exemplo n.º 18
0
void printSmallMatrixCVChar(char *title, cv::InputArray inArr)
{
  printf("%s\n", title);
  printf("----------------------------------\n");

  for (int rows = 0; rows < inArr.getMat().rows; rows++) {
    printf("ROW: %02d --->  ", rows);

    for (int cols = 0; cols < IMG_WIDTH; cols++) {
      printf(" %04d ", inArr.getMat().at<unsigned char>(rows, cols));
    }
    printf("\n");
  }
  printf("\n");
}
Exemplo n.º 19
0
Arquivo: Tools.cpp Projeto: glfpes/VLP
 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;
   }
 }
    void BackgroundSubtractorMedian::operator()(cv::InputArray _image, cv::OutputArray _fgmask, double learningRate)
    {
	framecount++;
	cv::Mat image = _image.getMat();
	if (image.channels() > 1) {
	    cvtColor(image,image,CV_BGR2GRAY);
	}
	if (image.cols == 0 || image.rows == 0) {
	    return;
	}
	_fgmask.create(image.size(), CV_8U);
	cv::Mat fgmask = _fgmask.getMat();
	if (!init)
	{
	    init = true;
	    bgmodel = cv::Mat(image.size(), CV_8U);
	}
	//printf("(%d,%d)(%d) ",image.cols,image.rows,image.type());
	//printf("(%d,%d)(%d)\n",bgmodel.cols,bgmodel.rows,bgmodel.type());

	cv::Mat cmpArr = cv::Mat(image.size(),CV_8U);
	cv::compare(image, bgmodel, cmpArr, CV_CMP_GT);
	cv::bitwise_and(cmpArr, 1, cmpArr);
	cv::add(bgmodel, cmpArr, bgmodel);

	cmpArr = cv::Mat(image.size(),CV_8U);
	cv::compare(image, bgmodel, cmpArr, CV_CMP_LT);
	cv::bitwise_and(cmpArr, 1, cmpArr);
	cv::subtract(bgmodel, cmpArr, bgmodel);

	cv::absdiff(image, bgmodel,fgmask);
	cv::threshold(fgmask,fgmask,fg_threshold,255,CV_THRESH_TOZERO);
	cv::medianBlur(fgmask,fgmask,median_filter_level);
    }
// Computes an Lidfaces model with images in src and corresponding labels
// in labels.
void Lidfaces::train(cv::InputArrayOfArrays src, cv::InputArray labels)
{
    std::vector<std::vector<cv::KeyPoint> > allKeyPoints;
    cv::Mat descriptors;

    // Get SIFT keypoints and LID descriptors
    detectKeypointsAndDescriptors(src, allKeyPoints, descriptors);

    // kmeans function requires points to be CV_32F
    descriptors.convertTo(descriptors, CV_32FC1);

    // Do k-means clustering
    const int CLUSTER_COUNT = params::lidFace::clustersAsPercentageOfKeypoints*descriptors.rows;
    cv::Mat histogramLabels;

    // This function populates histogram bin labels
    // The nth element of histogramLabels is an integer which represents the cluster that the
    // nth element of allKeyPoints is a member of.
    kmeans(
        descriptors, // The points we are clustering are the descriptors
        CLUSTER_COUNT, // The number of clusters (K)
        histogramLabels, // The label of the corresponding keypoint
        params::kmeans::termCriteria,
        params::kmeans::attempts,
        params::kmeans::flags,
        mCenters);

    // Convert to single channel 32 bit float as the matrix needs to be in a form supported
    // by calcHist
    histogramLabels.convertTo(histogramLabels, CV_32FC1);

    // We end up with a histogram for each image
    const size_t NUM_IMAGES = getSize(src);
    std::vector<cv::Mat> hists(NUM_IMAGES);
    // mCodebook.resize(NUM_IMAGES);

    // The histogramLabels vector contains ALL the points from EVERY image. We need to split
    // it up into groups of points for each image.
    // Because there are the same number of points in each image, and the points were put
    // into the labels vector in order, we can simply divide the labels vector evenly to get
    // the individual image's points.
    std::vector<cv::Mat> separatedLabels;
    for (unsigned int i = 0, startRow = 0; i < NUM_IMAGES; ++i)
    {
        separatedLabels.push_back(
            histogramLabels.rowRange(
                startRow,
                startRow + allKeyPoints[i].size()));
        startRow += allKeyPoints[i].size();
    }

    // Populate the hists vector
    generateHistograms(hists, separatedLabels, CLUSTER_COUNT);

    // Make the magnitude of each histogram equal to 1
    normalizeHistograms(hists);

    mCodebook = hists;
    mLabels = labels.getMat();
}
Exemplo n.º 22
0
void showWindow(const string &winName, cv::InputArray mat)
{
	Mat temp(mat.size(), mat.type());
	mat.getMat().copyTo(temp);
	namedWindow(winName, WINDOW_NORMAL); // Create a window for display.
	imshow(winName, temp); // Show our image inside it.
}
Exemplo n.º 23
0
int boostColor(cv::InputArray src, cv::OutputArray dst, float intensity)
{
    const int MAX_INTENSITY = 255;

    Mat srcImg = src.getMat();

    CV_Assert(srcImg.channels() == 3);
    CV_Assert(intensity >= 0.0f && intensity <= 1.0f);

    if (srcImg.type() != CV_8UC3)
    {
        srcImg.convertTo(srcImg, CV_8UC3);
    }

    Mat srcHls;
    cvtColor(srcImg, srcHls, CV_BGR2HLS);
    
    int intensityInt = intensity * MAX_INTENSITY;
    srcHls += Scalar(0, 0, intensityInt);
    
    cvtColor(srcHls, dst, CV_HLS2BGR);
    
    dst.getMat().convertTo(dst, srcImg.type());
    return 0;
}
Exemplo n.º 24
0
void EdgeDetector_<ParallelUtils::eGLSL>::apply_async_glimpl(cv::InputArray _oNextImage, bool bRebindAll, double dThreshold) {
    m_dCurrThreshold = dThreshold;
    cv::Mat oNextInputImg = _oNextImage.getMat();
    CV_Assert(oNextInputImg.size()==m_oFrameSize);
    CV_Assert(oNextInputImg.isContinuous());
    GLImageProcAlgo::apply_async(oNextInputImg,bRebindAll);
}
Exemplo n.º 25
0
void IEdgeDetector_GLSL::apply_gl(cv::InputArray _oNextImage, bool bRebindAll, double dThreshold) {
    lvAssert_(GLImageProcAlgo::m_bGLInitialized,"algo must be initialized first");
    m_dCurrThreshold = dThreshold;
    cv::Mat oNextInputImg = _oNextImage.getMat();
    lvAssert_(oNextInputImg.size()==GLImageProcAlgo::m_oFrameSize,"input image size must match initialization size");
    lvAssert_(oNextInputImg.isContinuous(),"input image must be continuous");
    GLImageProcAlgo::apply_gl(oNextInputImg,bRebindAll);
}
Exemplo n.º 26
0
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();
    
    // create(int minDisparity, int numDisparities, int blockSize,)
    Ptr<StereoSGBM> matcher = StereoSGBM::create(minDisparity, numDisparities, SADWindowSize);
    matcher->setP1(P1);
    matcher->setP2(P2);
    matcher->compute(img1, img2, dis);
    
	//StereoSGBM matcher(minDisparity, numDisparities, SADWindowSize, P1, P2);
	//matcher(img1, img2, dis);
	dis = dis / 16.0;
}
Exemplo n.º 27
0
inline void normAssert(cv::InputArray ref, cv::InputArray test, const char *comment = "",
                       double l1 = 0.00001, double lInf = 0.0001)
{
    double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total();
    EXPECT_LE(normL1, l1) << comment;

    double normInf = cvtest::norm(ref, test, cv::NORM_INF);
    EXPECT_LE(normInf, lInf) << comment;
}
Exemplo n.º 28
0
	void _SLICSegment2Vector3D_(cv::InputArray segment, cv::InputArray signal, T invalidValue, std::vector<std::vector<cv::Point3_<S>>>& segmentPoint)
	{
		Mat sig = signal.getMat();
		Mat seg = segment.getMat();

		for (int j = 0; j < seg.rows; ++j)
		{
			int* s = seg.ptr<int>(j);
			T* value = sig.ptr<T>(j);
			for (int i = 0; i < seg.cols; ++i)
			{
				if (value[i] != invalidValue)
				{
						segmentPoint[s[i]].push_back(Point3_<S>((S)i, (S)j, (S)value[i]));
				}
			}
		}
	}
Exemplo n.º 29
0
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);
}
Exemplo n.º 30
0
void IBackgroundSubtractor_GLSL::apply_gl(cv::InputArray _oNextImage, bool bRebindAll, double dLearningRate) {
    glAssert(m_bInitialized && m_bModelInitialized);
    m_dCurrLearningRate = dLearningRate;
    cv::Mat oNextInputImg = _oNextImage.getMat();
    CV_Assert(oNextInputImg.type()==m_nImgType && oNextInputImg.size()==m_oImgSize);
    CV_Assert(oNextInputImg.isContinuous());
    ++m_nFrameIdx;
    GLImageProcAlgo::apply_gl(oNextInputImg,bRebindAll);
    oNextInputImg.copyTo(m_oLastColorFrame);
}