Exemplo n.º 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);
			}
		}
	}

}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
void CBATCHDlg::OnBnClickedButtonLocation2()
{

	CPlateLocate plate;	plate.setDebug(1);
	//plate.setVerifyMax(500);
	//plate.setVerifyMin(50);
	
	for(vector<CString>::size_type v_i = 0; v_i < m_images.size(); ++v_i)
	{			
		string str = m_images[v_i].GetBuffer(0);

		int index1 = str.find_last_of("\\");
		int index2 = str.find_last_of(".");
		string name = str.substr(index1 + 1,index2 - index1 - 1);

		vector<Mat> resultVec;
		Mat src = imread(str, 1);
		int result = plate.plateLocate2(src, resultVec);
		if (result == 0)
		{
			int num = resultVec.size();
			if(1 == num)
			{
				Mat resultMat = resultVec[0];
				stringstream ss(stringstream::in | stringstream::out);
				ss << this->m_savepath << "\\" << name << ".jpg";
				imwrite(ss.str(), resultMat);
			}
			else
			{
				for (int j = 0; j < num; j++)
				{
					Mat resultMat = resultVec[j];
					stringstream ss(stringstream::in | stringstream::out);
					ss << this->m_savepath << "\\" << name << "_" << j << ".jpg";
					imwrite(ss.str(), resultMat);
				}
			}

		}
	}
	
	MessageBox("Finish.");
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
int test_plate_locate()
{
	cout << "test_plate_locate" << endl;

	Mat src = imread(img_plate_locate);

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

	vector<Mat> resultPlates;

	vector<CPlate> color_Plates;
	vector<CPlate> sobel_Plates;
	vector<CPlate> color_result_Plates;
	vector<CPlate> sobel_result_Plates;

	vector<CPlate> all_result_Plates;

	const int color_find_max = 4;

	plate.plateColorLocate(src, color_Plates);
	for (int i = 0; i<color_Plates.size(); ++i)
		color_result_Plates.push_back(color_Plates[i]);

	for (int i = 0; i< color_result_Plates.size(); i++)
	{
		CPlate plate = color_result_Plates[i];
		all_result_Plates.push_back(plate);
	}

	//颜色和边界闭操作同时采用
	{
		plate.plateSobelLocate(src, sobel_Plates);

		for (int i = 0; i<sobel_Plates.size(); ++i)
		{
			sobel_result_Plates.push_back(sobel_Plates[i]);
		}

		for (int i = 0; i< sobel_result_Plates.size(); i++)
		{
			CPlate plate = sobel_result_Plates[i];
			plate.bColored = false;

			all_result_Plates.push_back(plate);
		}
	}

	for (int i = 0; i < all_result_Plates.size(); i++)
	{
		// 把截取的车牌图像依次放到左上角
		CPlate plate = all_result_Plates[i];
		Mat resultMat = plate.getPlateMat();
		imshow("plate_locate", resultMat);
		waitKey(0);
	}

	destroyWindow("plate_locate");

	/*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 0;
}