本文整理汇总了C++中ImageReader::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageReader::LoadFile方法的具体用法?C++ ImageReader::LoadFile怎么用?C++ ImageReader::LoadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageReader
的用法示例。
在下文中一共展示了ImageReader::LoadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
ImageReader imgReader;
imgReader.LoadFile("roadresult.tif");
//cv::Mat img, image;
//try {
//image = cv::imread("roadresult.tif", CV_LOAD_IMAGE_UNCHANGED );
//}
//catch (cv::Exception e) {
// cout << e.err << std::endl ;
//}
//cv::cvtColor(image, img, CV_RGB2GRAY);
//int iType = img.type();
int iType = imgReader.m_data.depth();
if(! imgReader.m_data.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
//cv::Mat src;
//imgReader.m_data.convertTo(src, CV_8U);
//cv::Mat src_gray, threshold_output;
// need 3or4channel
//cv::cvtColor(src, src_gray, CV_BGR2GRAY);
//cv::blur(imgReader.m_data, src_gray, Size(1, 1));
std::vector<vector<Point>> contours;
vector<Vec4i> hierarchy;
// 8uc1 32fc1
//threshold(imgReader.m_data, imgReader.m_data, 100, 255, THRESH_BINARY);
// need 8uc1, 32sc1
//int iii = CV_32SC1;
//cv::Mat helpframe2;
//imgReader.m_data.convertTo(helpframe2, CV_32S);
//iii = helpframe2.depth();
findContours(imgReader.m_data, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
vector<vector<Point>> contours_poly(contours.size());
vector<Rect> boundRect(contours.size());
//vector<Point2f> center(contours.size());
//vector<float> radius(contours.size());
vector<MyStruct> angle_rect;
for (int i = 0; i < (int)contours.size(); i++)
{
approxPolyDP(cv::Mat(contours[i]), contours_poly[i], 3, true);
boundRect[i] = boundingRect(cv::Mat(contours_poly[i]));
//minEnclosingCircle((Mat)contours_poly[i], center[i], radius[i]);
MyStruct ms;
if (contours_poly[i].size() > 1)
{
Point tl, tr, bl, br;
tl = boundRect[i].tl();
tr = tl;
tr.x = tl.x + boundRect[i].width - 1;
br = boundRect[i].br();
br.x -= 1;
br.y -= 1;
bl = br;
bl.x = br.x - boundRect[i].width + 1;
vector<Point>::iterator iter1 = std::find(contours_poly[i].begin(), contours_poly[i].end(), tr);
vector<Point>::iterator iter2 = std::find(contours_poly[i].begin(), contours_poly[i].end(), bl);
if (iter1 != contours_poly[i].end() || iter2 != contours_poly[i].end())
{
ms.type = 1;
ms.rc = boundRect[i];
}
else
{
ms.type = 0;
ms.rc = boundRect[i];
}
}
else
{
ms.rc = boundRect[i];
ms.type = 0;
}
angle_rect.push_back(ms);
}
Mat drawing = Mat::zeros(imgReader.m_data.size(), CV_8UC3);
RNG rng(12345);
for (int i = 0; i < (int)contours.size(); i++)
{
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
//.........这里部分代码省略.........