前提・実現したいこと
c++にて
ディレクトリ内のjpgファイルをすべて読み込んで img_load_func関数に引数で渡したいです。
(unsigned charをfor分から外してコンパイルすると)pを出力すると下記結果となっています。
p出力結果
.\test\0213test.jpg .\test\test\0213test.jpg .\test\test\0213test.jpg .....
viusalstudio2015でfilesysytemを使用しています。
実現できればこの方法でなくても問題ありませんので、
よろしくお願いします。
発生している問題・エラーメッセージ
現状pをimg_load_funcに引数で渡すと下記エラーとなります。
Error (active) no suitable conversion function from "const std::experimental::filesystem::v1::directory_entry" to "char *" exists nnpack_testc: \Users\…\nnpack_test\nnpack_test.cpp
該当のソースコード
c++
1#include <iostream> 2#include <fstream> 3#include <string> 4#include <filesystem> 5namespace fs = std::experimental::filesystem::v1; 6 7int main(int argc, char *argv[]) 8{ 9 .... コード省略 10 11 int width, height; 12 char* filename = argv[2]; 13 14 IMG_LOAD_FUNC img_load_func = (IMG_LOAD_FUNC)GetProcAddress(hDLL, "load_image"); 15 if (img_load_func == NULL) { 16 std::cerr << "Failed to get address of load_image!" << std::endl; 17 fflush(stdout); 18 FreeLibrary(hDLL); 19 return -1; 20 } 21 std::string path = filename; 22 for (auto & p : fs::directory_iterator(path)) { 23 std::cout << p << std::endl; 24 25 unsigned char* pixels = img_load_func(p, &width, &height); 26 fflush(stdout); 27} 28 29.... コード省略 30return 0; 31} 32
補足情報(FW/ツールのバージョンなど)
visual studio2015
回答2件
あなたの回答
tips
プレビュー