0
我已經將一組圖像的路徑寫入文本文件中。我試圖在opencv中連續讀取圖像。然後我需要從每個圖像中找到一些特徵。但是我的方法不會讀取文件中提到的路徑中的圖像。這是我的代碼:從文本文件中提到的路徑中讀取圖像
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include <vector>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("hmv.txt", "r");
if (fp == NULL)
exit(EXIT_FAILURE);
while ((read = getline(&line, &len, fp)) != -1)
{
printf("%s",line);
Mat image = imread(line);
Ptr<FeatureDetector> featureDetector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;
featureDetector->detect(image, keypoints);
Ptr<DescriptorExtractor> featureExtractor = DescriptorExtractor::create("SIFT");
Mat descriptors;
featureExtractor->compute(image, keypoints, descriptors);
//Mat MyMat=cvCreateMat(descriptors.rows,descriptors.cols,CV_64FC1);
Mat output;
reduce(descriptors,output,0,CV_REDUCE_SUM,CV_64FC1);
string filename="feature.txt";
FILE *file;
file=fopen(filename,"wb");
fwrite(&output,
}
return 0;
}
請幫助,這是什麼缺陷?
錯誤/問題如何顯示?你的程序是否無法編譯?如果是,請告訴我們關於錯誤信息的更多信息。如果不是,請更具體地說明預期的結果和實際得到的結果?你如何確定你的程序存在缺陷? – 2013-05-11 17:57:39