【发布时间】:2016-06-23 00:07:10
【问题描述】:
我对 C++ 和 OpenCV 非常陌生,但对 Matlab 更熟悉。我有一项任务需要转移到 C++ 以加快处理速度。所以我想请教您对图像处理问题的建议。我在一个文件夹中有 10 张图像,我可以像在 this 中一样使用 dirent.h 来读取它们,并通过在 while 循环中调用 frame[count] = rawImage 来提取每一帧:
int count = 0;
std::vector<cv::Mat> frames;
frames.resize(10);
while((_dirent = readdir(directory)) != NULL)
{
std::string fileName = inputDirectory + "\\" +std::string(_dirent->d_name);
cv::Mat rawImage = cv::imread(fileName.c_str(),CV_LOAD_IMAGE_GRAYSCALE);
frames[count] = rawImage; // Insert the rawImage to frames (this is original images)
count++;
}
现在我想访问每个帧并进行类似于 Matlab 的计算,以获得另一个矩阵 A,例如 A = frames(:,:,1)+2*frames(:,:,2)。该怎么做?
【问题讨论】: