当前位置: 首页>>代码示例>>C++>>正文


C++ Mat1b::copyTo方法代码示例

本文整理汇总了C++中Mat1b::copyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat1b::copyTo方法的具体用法?C++ Mat1b::copyTo怎么用?C++ Mat1b::copyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mat1b的用法示例。


在下文中一共展示了Mat1b::copyTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fht_vertical

void fht_vertical(Mat1b &input, Mat1i &outputl, Mat1i &outputr)
{
  
  // увеличение размера
  int st = 1;
  while (st < input.rows)
    st *= 2;
  Mat1b myInput(st, input.cols);
  myInput = 0;
  Mat roi(myInput, Rect(0,0,input.cols,input.rows));
  input.copyTo(roi);
 
  fht_vertical_iteration_l(myInput, outputl, 0, st);
  fht_vertical_iteration_r(myInput, outputr, 0, st);
  //imshow("output_fht_l", outputl * 10);
  //imshow("output_fht_r", outputr * 10);

  Mat1i revtestl, testl;
  
  //imshow ("testl", testl * 10);
 // cout << outputl.rows << " " << testr.rows << endl;
  //imshow("0", (testl - outputl) * 100);
  
  //imshow("output_test", out * 10);
  //cvWaitKey(0);
  // DrawLines(myInput, outputl, outputr, 4000);
   
}
开发者ID:vokintsop,项目名称:visiworld,代码行数:28,代码来源:fht.cpp

示例2: test_fht_vertical_l

void test_fht_vertical_l(Mat1b &input,  Mat1i &output)
{
  int st = 1;
  while (st < input.rows)
    st *= 2;
  Mat1b myInput(st, input.cols);
  myInput = 0;
  Mat roi(myInput, Rect(0,0,input.cols,input.rows));
  input.copyTo(roi);

  Mat1b rev = myInput - myInput;
  Mat1i revtestl, testl;
  for (int x = 0; x < myInput.cols; ++x)
  {
    for (int y = 0; y < myInput.rows; ++y)
    {
      rev(y, x) = myInput(y, myInput.cols - x - 1); 
    }
  }
  test_fht_vertical_r(rev, revtestl);
  testl = revtestl - revtestl;
  for (int x = 0; x < myInput.cols; ++x)
  {
    for (int y = 0; y < myInput.rows; ++y)
    {
      testl(y, x) = revtestl(y, myInput.cols - x - 1); 
    }
  }

  output = testl;
}
开发者ID:vokintsop,项目名称:visiworld,代码行数:31,代码来源:fht.cpp

示例3: DrawLines

void DrawLines(Mat1b &input, Mat1i &outputL, Mat1i &outputR, int trash)//рисует все линии вес которых больше чем trash
// для тестирования
{
  Mat1b draw_mat;
  input.copyTo(draw_mat);
  
  draw_mat = draw_mat * 10;
  for (int x = 0; x < outputR.cols; ++x)
    for (int s = 0; s < outputR.rows; ++s)
	    if (outputR(s, x) > trash)
		    line(draw_mat, Point(x, 0), Point(x + s, outputR.rows - 1),  255, 1);
  for (int x = 0; x < outputL.cols; ++x)
    for (int s = 0; s < outputL.rows; ++s)
      if (outputL(s, x) > trash)
		    line(draw_mat, Point(x, 0), Point(x - s, outputL.rows - 1),  255, 1);
  imshow ("lines_more_the_tresh", draw_mat);
  //cout << draw_mat.cols << " " << draw_mat.rows << endl;
  //cvWaitKey(0);
}
开发者ID:vokintsop,项目名称:visiworld,代码行数:19,代码来源:fht.cpp

示例4: test_fht_vertical_r

void test_fht_vertical_r(Mat1b &input,  Mat1i &output)
{
  int st = 1;
  while (st < input.rows)
    st *= 2;
  Mat1b myInput(st, input.cols);
  myInput = 0;
  Mat roi(myInput, Rect(0,0,input.cols,input.rows));
  input.copyTo(roi);

  output = Mat1i(st, myInput.cols);

  for (int i = 0; i < myInput.cols; ++i)
  {
    for (int i1 = 0; i1 < st; ++i1)
    {
      output(i1, i) = test_fht_vertical_line(myInput, Point(i, 0), Point(i + i1 + 1, st));
    }
  }
}
开发者ID:vokintsop,项目名称:visiworld,代码行数:20,代码来源:fht.cpp

示例5: fillPerspectiva

Mat1b Helper::fillPerspectiva(const Mat1b &imgROI, const Rect &roi, const Size &tamanho, const uchar _default) {
	Mat1b perspectiva = Mat1b(tamanho, uchar(_default));
	imgROI.copyTo(perspectiva(roi));
	return perspectiva;
}
开发者ID:LCAD-UFES,项目名称:carmen_lcad,代码行数:5,代码来源:Helper.cpp

示例6: main

int main(int argc, char** argv)
{
   if(argc != 2){
	cout<<"Provide input image";
        return 0;
   }

    // Read image
    Mat3b img = imread(argv[1]);

    // Binarize image. Text is white, background is black
    Mat1b bin;
    cvtColor(img, bin, COLOR_BGR2GRAY);
    bin = bin < 200;

    // Rotate the image according to the found angle
    Mat1b rotated;
    bin.copyTo(rotated);

   // Mat M = getRotationMatrix2D(box.center, box.angle, 1.0);    //warpAffine(bin, rotated, M, bin.size());

    // Compute horizontal projections
    Mat1f horProj;
    reduce(rotated, horProj, 1, CV_REDUCE_AVG);

    // Remove noise in histogram. White bins identify space lines, black bins identify text lines
    float th = 0;
    Mat1b hist = horProj <= th;

    // Get mean coordinate of white pixels groups
    vector<int> ycoords;
    int y = 0;
    int count = 0;
    bool isSpace = false;
    for (int i = 0; i < rotated.rows; ++i)
    {
        if (!isSpace)
        {
            if (hist(i))
            {
                isSpace = true;
                count = 1;
                y = i;
            }
        }
        else
        {
            if (!hist(i))
            {
                isSpace = false;
                ycoords.push_back(y / count);
            }
            else
            {
                y += i;
                count++;
            }
        }
    }
    // Draw line as final result
    Mat3b result;
    cvtColor(rotated, result, COLOR_GRAY2BGR);

if(ycoords.size()>0){
    for (int i = 0; i < ycoords.size()-1; i++)
    {
	Rect rect1;
	rect1.x = 0;
	rect1.y = ycoords[i];
	rect1.width = result.size().width;
	rect1.height = ycoords[i+1]-ycoords[i];
        if(rect1.height > 30){
		Mat Image1 = result(rect1);
		imshow("Display Image", Image1); 
		string name = "";
		std::stringstream ss; 
		ss << i;
		name = "Image"+ss.str()+".jpg";
		imwrite(name,Image1);
		waitKey(0);
        }
	if(i == ycoords.size()-2){
		Rect rect1;
		rect1.x = 0;
		rect1.y = ycoords[i+1];
		rect1.width = result.size().width;
		rect1.height = result.size().height-ycoords[i+1];
		if(rect1.height > 30){
			Mat Image1 = result(rect1);
			imshow("Display Image", Image1); 
			string name = "";
			std::stringstream ss; 
			ss << i+1;
			name = "Image"+ss.str()+".jpg";
			imwrite(name,Image1);
			waitKey(0);
		}	
	}
    }
}
//.........这里部分代码省略.........
开发者ID:karthikakaran,项目名称:Handwritten-Grocery-List-Detection,代码行数:101,代码来源:Segmentation.cpp

示例7: featureI

void Nieto::featureI(const Mat1b &inBinaryFrameFiltradoRoiIPM, const Mat1b &grayFrameRoiIPM, map<string, double> &outMeans0, map<string, double> &outCovs0, map<string, double> &outWeights0, bool aplicarSobel) {
	
	double tempoInicio = static_cast<double>(getTickCount());
	
	Size imgSize = inBinaryFrameFiltradoRoiIPM.size();
	Mat1b binaryFrameFiltradoRoiIPMDilated;
	if (aplicarSobel) {
		// aplica o Sobel
		Mat1b grayFrameRoiIPMSobel, grayFrameRoiIPMSobelX, grayFrameRoiIPMSobelY;
		Sobel(grayFrameRoiIPM, grayFrameRoiIPMSobelX, CV_8U, 1, 0);
		Sobel(grayFrameRoiIPM, grayFrameRoiIPMSobelY, CV_8U, 0, 1);
		addWeighted(grayFrameRoiIPMSobelX, 0.5, grayFrameRoiIPMSobelY, 0.5, 0, grayFrameRoiIPMSobel);
		Mat1b binaryFrameRoiIPMSobel;
		threshold(grayFrameRoiIPMSobel, binaryFrameRoiIPMSobel, 20, 255, THRESH_BINARY);
		imshow("grayFrameRoiIPMSobel", binaryFrameRoiIPMSobel);

		// aplica um close para remover as sujeiras
		erode(binaryFrameRoiIPMSobel, binaryFrameRoiIPMSobel, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)), Point(-1, -1));
		dilate(binaryFrameRoiIPMSobel, binaryFrameRoiIPMSobel, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)), Point(-1, -1));

		// dilata para formar a m�scara
		int morph_size = 5;
		Mat1b dilate_kernel = getStructuringElement(MORPH_ELLIPSE, Size(1 * morph_size + 1, 1 * morph_size + 1), Point(morph_size, morph_size));
		dilate(binaryFrameRoiIPMSobel, binaryFrameFiltradoRoiIPMDilated, dilate_kernel, Point(-1, -1), 3);
		imshow("binaryFrameFiltradoRoiIPMDilated", binaryFrameFiltradoRoiIPMDilated);
	} else {
		// aplica o dilate no filtro do nieto na IPM
		int morph_size = 5;
		Mat1b dilate_kernel = getStructuringElement(MORPH_ELLIPSE, Size(1 * morph_size + 1, 1 * morph_size + 1), Point(morph_size, morph_size));
		dilate(inBinaryFrameFiltradoRoiIPM, binaryFrameFiltradoRoiIPMDilated, dilate_kernel, Point(-1, -1), 3);
	}

	// Imagens que ser�o constru�das
	// - gray{i} = grayMasked
	// - binary{i} = bin�rio da gray{i}
	Mat1b grayPavement = Mat1b(imgSize, uchar(0));
	Mat1b binaryPavement = Mat1b(imgSize, uchar(0));
	Mat1b grayMarkings = Mat1b(imgSize, uchar(0));
	Mat1b binaryMarkings = Mat1b(imgSize, uchar(0));
	Mat1b grayObjects = Mat1b(imgSize, uchar(0));
	Mat1b binaryObjects = Mat1b(imgSize, uchar(0));
	Mat1b grayUnknown = Mat1b(imgSize, uchar(0));
	Mat1b binaryUnknown = Mat1b(imgSize, uchar(0));

	// valores iniciais das gaussianas
	map<string, Scalar> meansScalar, stddevScalar, weightsScalar;

	// somente o que � imagem, na IPM, ficar� branco
	Mat1b binaryIpmInvMask = Mat1b(imgSize);
	cv::bitwise_not(grayFrameRoiIPM == 0, binaryIpmInvMask);

	// ************************************** PAVEMENT
	// calcula as m�scaras
	cv::bitwise_not(binaryFrameFiltradoRoiIPMDilated, binaryPavement);
	cv::bitwise_and(binaryIpmInvMask, binaryPavement, binaryPavement);
	cv::bitwise_and(grayFrameRoiIPM, binaryPavement, grayPavement);
	// calcula a m�dia e covari�ncia do pavimento
	cv::meanStdDev(grayFrameRoiIPM, meansScalar["pavement"], stddevScalar["pavement"], binaryPavement);
	outMeans0["pavement"] = meansScalar["pavement"][0];
	outCovs0["pavement"] = stddevScalar["pavement"][0] * stddevScalar["pavement"][0];
	
	// ************************************** LANE MARKINGS
	// calcula as m�scaras
	grayFrameRoiIPM.copyTo(grayMarkings);
	double thresMarkings = outMeans0["pavement"] + 3 * stddevScalar["pavement"][0];
	binaryMarkings = grayMarkings > thresMarkings;
	cv::bitwise_and(grayFrameRoiIPM, binaryMarkings, grayMarkings);
	// calcula a m�dia e covari�ncia dos lane markings
	cv::meanStdDev(grayFrameRoiIPM, meansScalar["markings"], stddevScalar["markings"], binaryMarkings);
	outMeans0["markings"] = meansScalar["markings"][0];
	outCovs0["markings"] = stddevScalar["markings"][0] * stddevScalar["markings"][0];
		
	// ************************************** OBJECTS
	// calcula as m�scaras
	grayFrameRoiIPM.copyTo(grayObjects);
	double thresObjects = outMeans0["pavement"] - 3 * stddevScalar["pavement"][0];
	binaryObjects = grayObjects < thresObjects;
	cv::bitwise_and(binaryIpmInvMask, binaryObjects, binaryObjects);
	cv::bitwise_and(grayFrameRoiIPM, binaryObjects, grayObjects);
	// calcula a m�dia e covari�ncia dos objetos
	cv::meanStdDev(grayFrameRoiIPM, meansScalar["objects"], stddevScalar["objects"], binaryObjects);
	outMeans0["objects"] = meansScalar["objects"][0];
	outCovs0["objects"] = stddevScalar["objects"][0] * stddevScalar["objects"][0];
		
	// ************************************** UNKNOWN
	// calcula as m�scaras
	cv::bitwise_or(binaryUnknown, binaryPavement, binaryUnknown);
	cv::bitwise_or(binaryUnknown, binaryObjects, binaryUnknown);
	cv::bitwise_or(binaryUnknown, binaryMarkings, binaryUnknown);
	cv::bitwise_not(binaryUnknown, binaryUnknown, binaryIpmInvMask);
	cv::bitwise_and(grayFrameRoiIPM, binaryUnknown, grayUnknown);
	// calcula a m�dia e covari�ncia dos desconhecidos
	cv::meanStdDev(grayFrameRoiIPM, meansScalar["unknown"], stddevScalar["unknown"], binaryUnknown);
	outMeans0["unknown"] = meansScalar["unknown"][0];
	outCovs0["unknown"] = stddevScalar["unknown"][0] * stddevScalar["unknown"][0];

	// calcula os pesos iniciais
	double nPavements = countNonZero(binaryPavement);
	double nMarkings = countNonZero(binaryMarkings);
	double nObjects = countNonZero(binaryObjects);
//.........这里部分代码省略.........
开发者ID:LCAD-UFES,项目名称:carmen_lcad,代码行数:101,代码来源:nieto.cpp


注:本文中的Mat1b::copyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。