简体   繁体   English

使用opencv和cURL从URL加载图像

[英]load an image from an url using opencv and cURL

I am trying to load an image from an url and display it.I am using opencv in c++ and cURL libraries.I am used to working with opencv,but I don't have any experience working with cURL libraries. 我试图从URL加载图像并显示它。我在c ++和cURL库中使用opencv。我曾经使用过opencv,但是我对使用cURL库没有任何经验。 I just need curl to load an image and save it in a cv::Mat file, so that I could display it. 我只需要卷曲就可以加载图像并将其保存在cv :: Mat文件中,以便可以显示它。 So, I took code from here .It is supposed to be working,but I am getting syntax errors. 因此,我从这里获取了代码。应该可以使用,但是却遇到语法错误。 Also,I tried this code from opencv.org. 另外,我尝试了来自opencv.org的这段代码。 But,I am getting same errors 但是,我遇到了同样的错误

Errors are 1>c:\\program files (x86)\\microsoft visual studio 10.0\\vc\\include\\cmath(19): error C2061: syntax error : identifier 'acosf' 错误是1> c:\\ program files(x86)\\ Microsoft Visual Studio 10.0 \\ vc \\ include \\ cmath(19):错误C2061:语法错误:标识符'acosf'

1>c:\\program files (x86)\\microsoft visual studio 10.0\\vc\\include\\cmath(19): error C2059: syntax error : ';' 1> c:\\ program files(x86)\\ Microsoft Visual Studio 10.0 \\ vc \\ include \\ cmath(19):错误C2059:语法错误:';'

and about 90 syntax errors.When I click on errors it is opening cmath file and I cant find any syntax errors there. 大约有90个语法错误。当我单击错误时,它正在打开cmath文件,而我在那里找不到任何语法错误。

Thank you for the help. 感谢您的帮助。

EDIT 1: I compiled the code as c++ and got rid of the above errors.Now I got a new error 编辑1:我将代码编译为c ++并摆脱了以上错误。现在我得到了一个新错误

OpenCV Error: Assertion failed (buf.data && buf.isContinuous()) in cv::imdecode_, file ........\\opencv\\modules\\highgui\\src\\loadsave.cpp OpenCV错误:断言失败(buf.data && buf.isContinuous())在cv :: imdecode_,文件........ \\ opencv \\ modules \\ highgui \\ src \\ loadsave.cpp中

It looks like you are compiling for c and not c++ . 看起来您正在为c而不是c++进行编译。 Check two things: 检查两件事:

  1. Code file extension is .cpp and not .c . 代码文件扩展名是.cpp而不是.c
  2. Check the compilation properties: Tools bar -> Project -> Properties (or Alt + F7)->Configuration Properties -> C/C++ -> Advanced -> Compile As: "Compile as C++ Code". 检查编译属性:工具栏->项目->属性(或Alt + F7)->​​配置属性-> C / C ++->高级->编译为:“编译为C ++代码”。

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

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