简体   繁体   English

使用 C 或 Opencv 获取文件的路径

[英]Getting path of a file using C or Opencv

I need to load an image into my program.我需要将图像加载到我的程序中。 I want to allow the user to browse for any image s/he wishes and open.我想让用户浏览她/他希望并打开的任何图像。 I need a function which asks the user to browse and select the desired file and can generate a string containing the complete path of that particular file.我需要一个 function 要求用户浏览和 select 所需的文件,并且可以生成包含该特定文件的完整路径的字符串。

You don't say on which platform you are working.你没有说你在哪个平台上工作。

If you are working on Windows, the fastest way is to use the OPENFILENAME structure with the GetOpenFileName function as shown in this example: http://msdn.microsoft.com/en-us/library/ms646829(v=vs.85).aspx#open_file . If you are working on Windows, the fastest way is to use the OPENFILENAME structure with the GetOpenFileName function as shown in this example: http://msdn.microsoft.com/en-us/library/ms646829(v=vs.85) .aspx#open_file You can then use cvLoadImage with the lpstrFile member of the structure.然后,您可以将 cvLoadImage 与结构的 lpstrFile 成员一起使用。

On linux, I would recommend using Qt and the QFileDialog.在 linux 上,我建议使用 Qt 和 QFileDialog。 Note that you can also use Qt on Windows.请注意,您也可以在 Windows 上使用 Qt。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM