Hello guys I am developing a simple openCV application with eclipse CDT;
Here is my code
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
cout << "M = " << endl << " " << M << endl << endl;
return 0;
}
I have built the project and when I try to run, I am getting this error
The program file specified in the launch configuration does not exist
D:\AndroidKeyStore\ExOpen\Debug\ExOpen.exe not found
Assuming the compilation didn't fail, the executable you're building appears to be different from the one you're trying to run in your configuration.
I'm not familiar with Eclipse CDT but you should
go to the Debug Configurations window for your project
select your launch configuration
change the exe you pasted above to the one your project is configured to build (you can find it in the project properties->C/C++ Build->Build directory)
Related
I want to link armadillo-11.4.0 to Code::blocks C++ project in Windows 11. I already gave the path to include folder and library folder using Project Build options>>Search directories. Also, in Build options>>linker settings I added the "libopenblas.lib" which is the precompiled openblas library I found in the armadillo\examples\lib_win64 folder. However, When I compile the example code given below, I get the following error.
ld.exe||cannot find -lopenblas.lib|
#include <iostream>
#include <armadillo>
using namespace arma;
int
main()
{
std::cout << "*** smoke test start" << std::endl;
uword N = 5;
mat A = reshape(regspace(1, N*N), N, N);
A.diag() += randu<vec>(N);
mat B;
bool status = expmat(B,A);
A.print("A:");
B.print("B:");
std::cout << ((status) ? "*** smoke test okay" : "*** smoke test failed") << std::endl;
return (status) ? 0 : -1;
}
Can someone explain me how to compile this successfully?
I downloaded a webcam_face_pose_ex.cpp file from GitHub and now i want to compile and run it on my mac.
#include <dlib/opencv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
#include <X11/Xlib.h>
using namespace dlib;
using namespace std;
int main()
{
try
{
cv::VideoCapture cap(0);
if (!cap.isOpened())
{
cerr << "Unable to connect to camera" << endl;
return 1;
}
image_window win;
// Load face detection and pose estimation models.
frontal_face_detector detector = get_frontal_face_detector();
shape_predictor pose_model;
deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model;
// Grab and process frames until the main window is closed by the user.
while(!win.is_closed())
{
// Grab a frame
cv::Mat temp;
if (!cap.read(temp))
{
break;
}
// Turn OpenCV's Mat into something dlib can deal with. Note that this just
// wraps the Mat object, it doesn't copy anything. So cimg is only valid as
// long as temp is valid. Also don't do anything to temp that would cause it
// to reallocate the memory which stores the image as that will make cimg
// contain dangling pointers. This basically means you shouldn't modify temp
// while using cimg.
cv_image<bgr_pixel> cimg(temp);
// Detect faces
std::vector<rectangle> faces = detector(cimg);
// Find the pose of each face.
std::vector<full_object_detection> shapes;
for (unsigned long i = 0; i < faces.size(); ++i)
shapes.push_back(pose_model(cimg, faces[i]));
// Display it all on the screen
win.clear_overlay();
win.set_image(cimg);
win.add_overlay(render_face_detections(shapes));
}
}
catch(serialization_error& e)
{
cout << "You need dlib's default face landmarking model file to run this example." << endl;
cout << "You can get it from the following URL: " << endl;
cout << " http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl;
cout << endl << e.what() << endl;
}
catch(exception& e)
{
cout << e.what() << endl;
}
}
I tried g++ webcam_face_pose_ex.cpp command but I get:
webcam_face_pose_ex.cpp:30:10: fatal error: 'dlib/opencv.h' file not found
#include <dlib/opencv.h>
^~~~~~~~~~~~~~~
1 error generated.
Was Wondering what I could do to fix this?
The Example File Is Not Meant to be Compiled Using g++
Read the following to learn a bit about the -I flag and #include statements:
The webcam_face_pose_ex.cpp is part of a larger project and you won't be able to compile it on its own because it depends on other files. The #include directive specifies that in order to compile this program, code from the file specified by #includemust be compiled first. This means the entire dlib must be downloaded before compiling webcam_face_pose_ex.cpp. This project also requires opencv2 so we can download it and place the opencv2 folder in the dlib project folder.
Now we can open terminal and change directory into the dlib project folder and compile the file using the following command:
g++ -I. examples/webcam_face_pose_ex.cpp
Note we're specifying the directory of where to find the files specified by #include using the -I parameter as -I. this means to search the current working directory for the files. There it will find the dlib folder and dlib/opencv.h.
How ever, this isn't enough. When you execute the command, you'll encounter an error opencv2/opencv_modules.hpp: No such file or directory.
Solution
The dlib project documentation states that the examples should be built using cmake. Make sure to use cmake to compile the examples.
After this question I found that OpenCV gives me this error:
Starting
C:\Users\nikola\Documents\build-ConsoleTry-Desktop_Qt_5_5_0_MSVC2013_64bit-Debug\debug\ConsoleTry.exe...
C:\Users\nikola\Documents\build-ConsoleTry-Desktop_Qt_5_5_0_MSVC2013_64bit-Debug\debug\ConsoleTry.exe exited with code -1073741701
after trying to run this console code:
#include <QCoreApplication>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace::cv;
using namespace::std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const char* filename = "1-page.png";
// cout << filename << endl;
cout << "111" << endl;
Mat src = imread(filename, 0);
cout << "222" << endl;
return a.exec();
}
How to fix it? I have copied DLL files in the debug directory. In this answer is mentioned the need of conversation of Mat to Qt QImage. Is this the case and are other objects required to be converted?
Result when start .exe from cmd.
Micka is right - it do need highgui, so I have copied all .dll files from D:\opencv_2411\opencv\build\x64\vc12\bin to debug directory. I was having hadeaches because before this I have copied all .dll files from my Visual Studio 2013 project directory, but they were x86, and the QT project is x64. Thank you all!!! And if someone still have problem see this topic too.
Just started a beginner c++ tutorial which eclipse is used. I am using a mac, so when creating a new project i chose the toolchain 'macxxx" something. In the video a different one is used because it is done in windows.
I tried running this super easy program :
#include <iostream>
using namespace std;
int main() {
cout <<'C++ is FUN'\n;
return 0;
}
When i click on the hammer to build it, I just get 3 errors :
Symbol 'cout' could not be resolved firstprogram.cpp Semantic Error
all similar to that.
How can i fix that ?
Does following code produce errors aswell?
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
}
You can end current line with << endl after "Some text to display". So it would look like
cout << "hello there " << endl;
I'm trying to write a small program that just runs two executables. Currently it only runs the first one for some reason:
#include <windows.h>
#include <iostream>
using namespace std;
main(){
cout << "Running Borderless Window..." << endl;
system("BorderlessWindowed.exe");
cout << "Running Diablo II MultiRes..." << endl;
system("D2MultiResGame.exe.lnk");
}
It's just a small program to run Diablo II + a BorderlessWindow program.
this will do the task
#include <windows.h>
#include <iostream>
using namespace std;
main(){
cout << "Running Borderless Window... and Diablo II MultiRes" << endl;
system("cmd /c start BorderlessWindowed.exe&&D2MultiResGame.exe.lnk");
// this is what i have tried
// system("cmd /c start notepad.exe&&mspaint.exe");
// which starts notepad and mspaint one after another
}
Alright since system() requires that the first process be done with before it launched the second I just created a batch file that starts both, and had the .exe launch the batch file.