示例#1
0
void CBATCHDlg::OnBnClickedButtonLocation()
{

	CPlateLocate plate;
	plate.setDebug(0);
	plate.setGaussianBlurSize(5);
	plate.setMorphSizeWidth(17);
	plate.setMorphSizeHeight(10);
	plate.setVerifyMin(8);
	plate.setVerifyMax(80);


	for(vector<CString>::size_type v_i = 0; v_i < m_images.size(); ++v_i)
	{	
		vector<Mat> resultVec;
		string str = m_images[v_i].GetBuffer(0);
		Mat src = imread(str, 1);
		int result = plate.plateLocate(src, resultVec);
		if (result == 0)
		{
			int num = resultVec.size();
			for (int j = 0; j < num; j++)
			{
				Mat resultMat = resultVec[j];
				//IplImage pImg = resultMat;
				stringstream ss(stringstream::in | stringstream::out);
				ss << this->m_savepath << "\\" << v_i << "_location" << j << ".jpg";
				imwrite(ss.str(), resultMat);
			}
		}
	}

}
		int pr_test_plate_locate()
		{
			cout << "test_plate_locate" << endl;

			const string file = "resources/image/plate_locate.jpg";

			cv::Mat src = imread(file);

			vector<cv::Mat> resultVec;
			CPlateLocate plate;
			//plate.setDebug(0);
			//plate.setLifemode(true);

			int result = plate.plateLocate(src, resultVec);
			if (result == 0) 
			{
				size_t num = resultVec.size();
				for (size_t j = 0; j < num; j++) 
				{
					cv::Mat resultMat = resultVec[j];
					imshow("plate_locate", resultMat);
					waitKey(0);
				}
				destroyWindow("plate_locate");
			}

			return result;
		}
示例#3
0
文件: test.cpp 项目: Candyf/CPR_MFC
int test_plate_locate()
{
	cout << "test_plate_locate" << endl;

	Mat src = imread("image/plate_locate.jpg");
	//Mat src = imread("image/baidu_image/test6.jpg");

	vector<Mat> resultVec;
	CPlateLocate plate;
	plate.setDebug(1);
	plate.setGaussianBlurSize(5);
	plate.setMorphSizeWidth(17);

	int result = plate.plateLocate(src, resultVec);
	if (result == 0)
	{
		int num = resultVec.size();
		for (int j = 0; j < num; j++)
		{
			Mat resultMat = resultVec[j];
			imshow("plate_locate", resultMat);
			waitKey(0);
		}
	}

	return result;
}
示例#4
0
文件: test.cpp 项目: kongqx/EasyPR
int test_plate_locate()
{
    cout << "test_plate_locate" << endl;

    Mat src = imread("image/test.jpg");

    vector<Mat> resultVec;
    CPlateLocate plate;
    plate.setDebug(1);
    plate.setLifemode(true);

    int result = plate.plateLocate(src, resultVec);
    if (result == 0)
    {
        int num = resultVec.size();
        for (int j = 0; j < num; j++)
        {
            Mat resultMat = resultVec[j];
            imshow("plate_locate", resultMat);
            waitKey(0);
        }
        destroyWindow("plate_locate");
    }

    return result;
}
示例#5
0
文件: test.cpp 项目: caomw/EasyPR
int test_plate_judge()
{
	cout << "test_plate_judge" << endl;

	Mat src = imread("image/plate_judge.jpg");

	//可能是车牌的图块集合
	vector<Mat> matVec;

	//经过SVM判断后得到的图块集合
	vector<Mat> resultVec;

	CPlateLocate lo;
	lo.setDebug(1);
	lo.setLifemode(true);

	int resultLo = lo.plateLocate(src, matVec);

	if (0 != resultLo)
		return -1;

	cout << "plate_locate_img" << endl;
	if (resultLo == 0)
	{
		int num = matVec.size();
		for (int j = 0; j < num; j++)
		{
			Mat resultMat = matVec[j];
			imshow("plate_judge", resultMat);
			waitKey(0);
		}
        destroyWindow("plate_judge");
	}

	CPlateJudge ju;
	int resultJu = ju.plateJudge(matVec, resultVec);

	if (0 != resultJu)
		return -1;

	cout << "plate_judge_img" << endl;
	if (resultJu == 0)
	{
		int num = resultVec.size();
		for (int j = 0; j < num; j++)
		{
			Mat resultMat = resultVec[j];
			imshow("plate_judge", resultMat);
			waitKey(0);
		}
        destroyWindow("plate_judge");
	}

	return resultJu;
}
示例#6
0
// 定位并判断车牌有无,放置在指定位置
void tag_data(const char* source_folder, const char* has_plate_folder,
              const char* no_plate_folder, const char* svm_model) {
  assert(source_folder);
  assert(has_plate_folder);
  assert(no_plate_folder);
  assert(svm_model);

  auto files = Utils::getFiles(source_folder);

  size_t size = files.size();
  if (0 == size) {
    std::cout << "No file found in " << source_folder << std::endl;
    return;
  }

  CPlateLocate locator;
  CPlateJudge judger;

  judger.LoadModel(svm_model);

  for (auto f : files) {
    auto filename = Utils::getFileName(f);
    std::cout << "Tagging: " << f << std::endl;

    // auto plate_string = plate_from_path(f);
    cv::Mat image = cv::imread(f);
    assert(!image.empty());

    std::vector<cv::Mat> maybe_plates;
    locator.plateLocate(image, maybe_plates);

    int plate_index = 0;
    for (auto plate : maybe_plates) {
      char save_to[255] = {0};
      int result = 0;
      judger.plateJudge(plate, result);
      if (result == 1) {
        // it's a plate
        sprintf(save_to, "%s/%s_%d.jpg",
                has_plate_folder, filename.c_str(), plate_index);
        std::cout << "[Y] -> " << save_to << std::endl;
      } else {
        // no plate found
        sprintf(save_to, "%s/%s_%d.jpg",
                no_plate_folder, filename.c_str(), plate_index);
        std::cout << "[N] -> " << save_to << std::endl;
      }
      utils::imwrite(save_to, plate);
      ++plate_index;
    }
  }
}
示例#7
0
文件: api.hpp 项目: daiyinger/EasyPR
static void plate_locate(const char* image, const bool life_mode = true) {
  cv::Mat src = cv::imread(image);

  _ASSERT(!src.empty());

  CPlateLocate plate;
  plate.setDebug(1);
  plate.setLifemode(life_mode);

  std::vector<cv::Mat> results;

  plate.plateLocate(src, results);
}
		int test_plate_locate_batch(const char*path) 
		{
			cout << "test_plate_locate" << endl;
			char* chCurPath = getcwd(NULL, 0);
			vector<cv::Mat> matVec;
			vector<cv::Mat> resultVec;
			CPlateLocate plate;

			vector<string> fileVec;
			cv::Mat src;
			fileVec = BrowseFilenamesOneLayer(path, "*.jpg");
 
			_chdir(chCurPath);
			cout << fileVec.size() << endl;
			for (int i = 0; i < fileVec.size(); i++)
			{
				string fileName = fileVec[i];
				cout << "fileName=" << fileName << endl;
				//const string file = "resources/image/plate_locate.jpg";
				src = imread(fileName);
				int result = plate.plateLocate(src, matVec);
				if (result == 0) 
				{
					size_t num = matVec.size();
					for (size_t j = 0; j < num; j++) 
					{
						cv::Mat resultMat = matVec[j];
						//imshow("plate_locate", resultMat);
						//waitKey(0);
						ostringstream os;
						char a[10];
						itoa(j, a, 10);
						os << "resources/image/general_test_pr/" << a << ".jpg";
						cout << os.str() << endl;
						imwrite(os.str(), resultMat);
					}
					//destroyWindow("plate_locate");
					
				}
			}

			return 0;
		}
int plate_locatte_main(vector<Mat>& resultDT){
	cout << "process plat_locatte_main...";

	Mat src = imread(NATIVE_RECG_PATH+"/test.jpg");

	CPlateLocate plate;
	plate.setDebug(OPTION_DEBUG);
	plate.setLifemode(OPTION_LIFEMODE);

	int result = plate.plateLocate(src, resultDT);
	if (result == 0)
	{
		int num = resultDT.size();
		for (int j = 0; j < num; j++)
		{
			Mat resultMat = resultDT[j];
			show_dialog(resultMat);
		}
		cout << "OK";
	}

	cout << endl;
	return result;
}