開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
OpenCV
問題(Question):
我想要做出判斷一個資料夾裡面有多少張ABC%d.bmp的圖
然後再拿最後一張圖來做辨識
因此我想到的方法是用while配合fopen來rb找到最後一張
再用opencv來imread
但是目前情況是
1.辨識到第43張圖時就會發生test和train檔案大小不符
(應該是開到ABC%d+1.bmp空檔去了)
2.只要我在程式後面加上fclose,進行辨識時就會發生
Caught SIGSEGV accessing address (nil)
Spinning. Please run 'gdb gst-launch 1321' to continue debugging, Ctrl-C to
quit, or Ctrl-\ to dump core.
困擾蠻久的,一直沒辦法找到好的方法解決,
麻煩大家幫忙看看了!謝謝!
程式碼(SourceCode):
int count = 0;
char iconpath[200];
FILE *fp;
sprintf(iconpath,"/var/ABC%d.bmp",count);
fp=fopen(iconpath,"rb");
while(fp){
count++;
sprintf(iconpath,"/var/ABC%d.bmp",count);
fp=fopen(iconpath,"rb");
}
sprintf(iconpath,"/var/ABC%d.bmp",count-1);
Mat img = imread(iconpath, CV_LOAD_IMAGE_GRAYSCALE);
memset(iconpath,0x00,200);
int predicted_label = -1;
double predicted_confidence = 0.0;
model->predict(img, predicted_label, predicted_confidence);
*label=predicted_label;
*conf=predicted_confidence;
fclose(fp);