Dev C++ with OpenCV compile error - c++

I'm using Dev C++ 4.9.9.2 and OpenCV 2.4.8, I'm also in Windows 7 x86. These are in my compiler setting, -L"D:\opencv\build\x86\vc12\bin" -lopencv_highgui248 -lopencv_core248 -lopencv_flann248 -lopencv_gpu248 -lopencv_imgproc248 -lopencv_legacy248 -lopencv_ml248 -lopencv_nonfree248 -lopencv_objdetect248 -lopencv_photo248 -lopencv_video248 -lopencv_ts248. Every time I compile my simple project, it shows this errors: Compiler:
OpenCV
Executing g++.exe...
g++.exe "D:\VS Projects\WebCam\WebCam\loadimg.cpp" -o "D:\VS Projects\WebCam\WebCam\loadimg.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -I"D:\opencv\build\include\opencv2" -I"D:\opencv\build\include" -L"C:\Dev-Cpp\lib" -L"D:\opencv\build\x86\vc12\lib" -g3
In file included from D:/opencv/build/include/opencv2/core/core.hpp:4854,
from D:/opencv/build/include/opencv2/opencv.hpp:47,
from D:\VS Projects\WebCam\WebCam\loadimg.cpp:1:
D:/opencv/build/include/opencv2/core/operations.hpp: In static member function `static cv::Ptr<_Tp2> cv::Algorithm::create(const std::string&)':
D:/opencv/build/include/opencv2/core/operations.hpp:3972: error: expected primary-expression before '>' token
D:/opencv/build/include/opencv2/core/operations.hpp:3972: error: expected primary-expression before ')' token
D:/opencv/build/include/opencv2/core/operations.hpp: At global scope:
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: got 2 template parameters for `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: but 1 required
D:/opencv/build/include/opencv2/core/operations.hpp:4033: error: redefinition of `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'
D:/opencv/build/include/opencv2/core/operations.hpp:4024: error: `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)' previously declared here
Edit:
there is my code.
include <opencv2/opencv.hpp>
#include <iostream>
#include <io.h>
using namespace cv;
using namespace std;
int main (int, char**)
{
cv::VideoCapture camera(1);
if(!camera.isOpened())
{
std::cerr << "ERROR: Could not open camera" << std::endl;
return 1;
}
cv::namedWindow("Webcam", CV_WINDOW_AUTOSIZE);
while(1)
{
cv::Mat frame;
camera >> frame;
cv::imshow("Webcam", frame);
if (cv::waitKey(30) >= 0)
{
imwrite("test.jpg", frame);
break;
}
}
return 0;
}
Execution terminated
Can you please help me on this? Please.
Thanks.

Related

Weird GDAL error for compilation

So I thought I installed GDAL correctly using aptitude, and all my makefile has is
` g++ main.cpp -I/usr/include/mysql -lmysqlclient -I/usr/include/gdal -lgdal1.7.0'
But I am getting this error on my make "ubuntu vm"
`g++ main.cpp -I/usr/include/mysql -lmysqlclient -I/usr/include/gdal -lgdal1.7.0
In file included from /usr/include/c++/4.6/vector:65:0,
from /usr/include/gdal/gdal_priv.h:58,
from main.cpp:5:
/usr/include/c++/4.6/bits/stl_vector.h: In member function ‘std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const’:
/usr/include/c++/4.6/bits/stl_vector.h:1244:40: error: expected unqualified-id before ‘(’ token
In file included from /usr/include/c++/4.6/vector:66:0,
from /usr/include/gdal/gdal_priv.h:58,
from main.cpp:5:
/usr/include/c++/4.6/bits/stl_bvector.h: In member function ‘std::vector<bool, _Alloc>::size_type std::vector<bool, _Alloc>::_M_check_len(std::vector<bool, _Alloc>::size_type, const char*) const’:
/usr/include/c++/4.6/bits/stl_bvector.h:1026:45: error: expected unqualified-id before ‘(’ token
make: *** [all] Error 1
`
Don't really know how to solve this one
Here is all my code:
#include <iostream>
#include "sql.h"
#include "gdal_priv.h"
#include "cpl_conv.h"
int main(int argc, char ** argv){
GDALDataset *poDataset;
return 0;
}
This looks more like an STL/vector issue than a GDAL specific problem. Something is going wrong when gdal_priv.h does
#include <vector>
I'd first check if you can compile something like this:
#include <vector>
int main(int argc, char ** argv){
std::vector<int> foo;
}

SFML VertexArray not member of sf

I have the following program for drawing a triangle with vertex arrays, as described in SFML tutorials.
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
try{
sf::RenderWindow Mywindow(sf::VideoMode(800,600),"TriColor Triangle!");
sf::VertexArray triangle(sf::Triangles, 3);
triangle[0].position = sf::Vector2f(5,5);
triangle[1].position = sf::Vector2f(50,5);
triangle[2].position = sf::Vector2f(50,50);
triangle[0].color = sf::Color::Red;
triangle[1].color = sf::Color::Blue;
triangle[2].color = sf::Color::Green;
Mywindow.draw(triangle);
}
catch( const std::runtime_error& e)
{
std::cout << e.what() << std::endl;
std::cin.ignore();
return EXIT_FAILURE;
}
std::cin.ignore();
return EXIT_SUCCESS;
}
The Makefile for compilation I am using is the following:
all: exe
exe: main.o
g++ main.o -o exe -lsfml-graphics -lsfml-window -lsfml-system
main.o: main.cpp
g++ -c main.cpp
The follwing error is being displayed:
make
g++ -c main.cpp
main.cpp: In function ‘int main()’:
main.cpp:11:2: error: ‘VertexArray’ is not a member of ‘sf’
main.cpp:11:18: error: expected ‘;’ before ‘triangle’
main.cpp:13:2: error: ‘triangle’ was not declared in this scope
main.cpp:21:11: error: ‘class sf::RenderWindow’ has no member named ‘draw’
main.cpp:23:33: error: expected unqualified-id before ‘&’ token
main.cpp:23:33: error: expected ‘)’ before ‘&’ token
main.cpp:23:33: error: expected ‘{’ before ‘&’ token
main.cpp:23:35: error: ‘e’ was not declared in this scope
main.cpp:23:36: error: expected ‘;’ before ‘)’ token
make: *** [main.o] Error 1
I don't understand why it is saying VertexArray not member of sf!
You must provide a path to the SFML lib dir and a path to the SFML include dir.
Like this:
"-IC:\\Path\\to\\your\\project\\your-lib-sub-dir\\SFML-2.1\\include"
"-LC:\\Path\\to\\your\\project\\your-lib-sub-dir\\SFML-2.1\\lib"
Another thing, to be able to see something, you should suround your draw call with something like this:
while(1){
Mywindow.clear(sf::Color::Black);
Mywindow.draw(triangle);
Mywindow.display();
}

FI_Init_FreeType variable declaration error

I am trying to write a simple program that uses freetype.
code :
#include <ft2build.h>
#include FT_FREETYPE_H
int main()
{
FT_Library library;
int error = FI_Init_FreeType(&library);
}
i am compiling as g++ try1_c++demo.cpp -I/usr/include/freetype2
it gives following error:
try1_c++demo.cpp: In function ‘int main()’:
try1_c++demo.cpp:9: error: ‘FI_Init_FreeType’ was not declared in this scope
how do i solve this error?

LEDA programming with c++:

I am a LEDA-6.3 user.
I have an error when compiling this simple code:
#include <LEDA/core/d_array.h>
#include <iostream>
using namespace std;
main()
{
d_array<string,string> dic;
dic["hello"] = "hallo";
dic["world"] = "Welt";
dic["book"] = "Buch";
dic["key"] = "Schluessel";
string s;
forall_defined(s,dic) cout << s << " " << dic[s] << endl;
}
G++ Compiler:
g++ -I$LEDAROOT/incl -L$LEDAROOT d_array.cpp /usr/lib/LEDA/libleda.a -lX11 -lm -o d_array
The ERROR:
d_array.cpp: In function ‘int main()’:
d_array.cpp:8: error: ‘d_array’ was not declared in this scope
d_array.cpp:8: error: expected primary-expression before ‘,’ token
d_array.cpp:8: error: expected primary-expression before ‘>’ token
d_array.cpp:8: error: ‘dic’ was not declared in this scope
Please if there is a guide for LEDA-6.3 give me the link
You probably mean leda::d_array or are forgetting using namespace leda;

Unable to compile simple jsoncpp program with Eclipse on LInux

The File is at the location /home/shivang/Desktop and the filename is sh1.cpp
Source code for the file is given below
#include iostream
#include json/json.h
#include json/reader.h
using namespace std;
using namespace Json;
int main() {
std::string example = "{\"array\":[\"item1\", \"item2\"], \"not an array\":\"asdf\"}";
Value value;
Reader reader;
bool parsed = reader.parse(example, value, false);
std::cout << parsed;
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
The following error messages are displayed.
/home/shivang/Desktop/sh1.cpp: In function ‘int main()’:
/home/shivang/Desktop/sh1.cpp:10:2: error: ‘Value’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:10:8: error: expected ‘;’ before ‘value’
/home/shivang/Desktop/sh1.cpp:11:2: error: ‘Reader’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:11:9: error: expected ‘;’ before ‘reader’
/home/shivang/Desktop/sh1.cpp:13:16: error: ‘reader’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:13:38: error: ‘value’ was not declared in this scope
Configuration gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
jsoncpp-src-0.5.0
eclipse-cpp-helios-SR2-linux-gtk
I have never used Json or C++ before. But a little googling around led me to this page. I think adding the following line to your list of includes should help:
#include <json/value.h>