OPENCV batch processing of images

Source: Internet
Author: User
Tags radar

In order to batch processing images, online search for a long time, basically are C language SPRINRF () and sprinrf_s () method; parameter input can only be char* type; here's a simple C + + approach.

#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <string>

using namespace CV;
using namespace Std;

int main ()
{
Mat Srcimage;
Mat Dstimage;
Mat Hsvimage;

String FileName;

char* FilePath = "e:\\ material \ \ Overseas bayonet four lane \ \ Radar 4-lane video _ Night \\201603152002\\dir.txt";
char* dir = "e:\\ material \ \ Overseas bayonet four lane \ \ Radar 4-lane video _ Night \\201603152002\\";

Ifstream InFile (FilePath);
if (!infile.is_open ())
{
cerr<< "Failed Open File" <<endl;
return-1;
}

Size sz;
Double scale = 0.25;

while (Getline (inFile, filename))//Read file names by row
{
cout<<dir<<endl;
cout<<filename<<endl;

String str = dir + fileName; Connection file path and file name;

cout<<str<<endl;

Srcimage = Imread (str,1); Read in image
if (!srcimage.data)
{
cout<< "Image is filed" <<endl;
return-1;
}
Sz.width = (int) (Srcimage.cols * 0.25);
Sz.height = (int) (srcimage.rows * 0.25);

Dstimage.create (SZ, Srcimage.type ());
Resize (srcimage, dstimage, SZ);
Namedwindow (filename,1);
Imshow (Filename,dstimage);
MoveWindow (FileName, srcimage.cols, 0);

Hsvimage.create (Sz,dstimage.type ());
Cvtcolor (Dstimage,hsvimage,cv_bgr2lab);//rgb Convert to Lab color space
Imshow ("HSV", hsvimage);

Waitkey (0);

DestroyWindow (FileName);
}


Infile.close ();
return 0;
}

OPENCV batch processing of images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.