opencv 3.4.1 visual studio 2017 - visual-studio

i'm runing a simple code
#include<opencv2/opencv.hpp>
#include"iostream"
using namespace std;
using namespace cv;
int main()
{
Mat image1 = imread("C:\\Users\\Public\\Pictures\\Sample Pictures\\Tulips.jpg");
Mat image = imread("Koala.jpg");
if (image.empty())
{
cout << "no image" << endl;
system("pause");
}
imshow("win1", image1);
waitKey(0);
imshow("win2", image);
waitKey(0);
return 0;
}
when i run the code using "start without debugging (ctrl+f5)" it runs fine and the ouput image appear.
but when i run it using "start debugging (f5)" it gives opencv_world341d.dll is missing.
how to fix this.

This happen because the application couldn't find the correct dll, there are 2 solutions for this problem.
Add dll to exe location
Add dll to system path
The "opencv_world341d.dll" can be found in this location $OPENCV_INSTALL_DIR/build/x64/vc15/bin
hope this helps...

Related

Xcode doesn't let me edit files

Newbie here. I'm trying to learn Xcode and I've written a simple code here that takes a string input from an Input file and is meant to print it out to an Output file. Easy stuff, if it wasn't that I cannot figure out why Xcode isn't letting be edit Input and Output files from within the app. Here's the code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream Input;
ofstream Output;
Input.open("Input.txt");
if(!Input)
{
cout << "Input file not found" << endl;
return 1;
}
Output.open("Output.txt");
if(!Output)
{
cout << "Output file not found" << endl;
return 3;
}
string prova;
Input >> prova;
Output << prova;
return 0;
}
To make absolutely clear what I mean the editor doesn't let me edit Input files, I've uploaded a video here, hope it helps. Thank you.
Specs: Xcode Version 11.4 -> can't update it to the last version because my Mac is too old / Mac OS Catilina Version 10.15.7

Visual Studio Intel Threading Building Blocks DLL error

I am using an example of Intel TBB code I found on SO:
#include "tbb/blocked_range.h"
#include "tbb/parallel_for.h"
#include "tbb/task_scheduler_init.h"
#include <iostream>
#include <vector>
struct mytask {
mytask(size_t n)
:_n(n)
{}
void operator()() {
for (int i=0;i<1000000;++i) {} // Deliberately run slow
std::cerr << "[" << _n << "]";
}
size_t _n;
};
struct executor
{
executor(std::vector<mytask>& t) :_tasks(t)
{}
executor(executor& e,tbb::split) :_tasks(e._tasks)
{}
void operator()(const tbb::blocked_range<size_t>& r) const {
for (size_t i=r.begin();i!=r.end();++i)
_tasks[i]();
}
std::vector<mytask>& _tasks;
};
int main(int,char**) {
tbb::task_scheduler_init init; // Automatic number of threads
// tbb::task_scheduler_init init(2); // Explicit number of threads
std::vector<mytask> tasks;
for (int i=0;i<1000;++i){
tasks.push_back(mytask(i));
}
executor exec(tasks);
tbb::parallel_for(tbb::blocked_range<size_t>(0,tasks.size()),exec);
std::cerr << std::endl;
return 0;
}
The code builds fine, but when I go to run I get the error:
The program can't start because tbb_debug.dll is missing from your
computer. Try reinstalling the program to fix this problem.
I think this is probably the path I need to set somewhere within VS2012:
C:\Program Files (x86)\Intel\Composer XE 2013 SP1\redist\ia32\tbb\vc11
because it contains tbb_debug.dll.
Where does this path need to be set?
EDIT: I tried setting in the "Executable directories" path section but that didnt work.
In solution explorer, right click the project and open "Properties"
Open "Configuration Properties" -> "Debugging".
In the "Environment" line, add "PATH=C:\Program Files (x86)\Intel\Composer XE 2013"
Make sure "Merge Environment" is set to "Yes".

opencv with visual studio 2010 error

I am trying to build my first opencv application, I added the include directories and the library directories and then added the linking input which is some opencv.lib files after running this code:
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat im = imread("c:/full/path/to/lena.jpg");
if (im.empty())
{
cout << "Cannot load image!" << endl;
return -1;
}
imshow("Image", im);
waitKey(0);
}
but I got this error:
The program can't start because libgcc_s_dw2-1.dll is missing from your computer.
the error list include:
Warning 1 warning D9002: ignoring unknown option '-static-libgcc' c:\Users\Kato\documents\visual studio 2010\Projects\cvtest\cvtest\cl cvtest
I added -static-libgcc to command line additional options but the same error.

OpenCV cannot load image

While I was working on a project, I noticed that I am not able to load images. Here is the simple code that I used to check:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
Mat gray_image;
cv::cvtColor(image, gray_image, CV_RGB2GRAY);
imwrite("Gray_Image.jpg",gray_image);
return 0;
}
Here is its output when I execute it:
root#beaglebone:~# ./tryit lena.jpg
Could not open or find the image
I tried to directly use the address of the image ("/home/root/lena.jpg") instead of argv[1] but nothing changed.
What can be the problem?
ps: I am cross-compiling this OpenCV program and then running it on my BeagleBone which has Angstrom Linux installed on it. Can this problem related to it?
I solved my problem by deleting existing OpenCV libraries on my angstrom image and replacing them with the working ones.
Try saving the image with a png extension and then opening it. For some reason, files with a png extension work better than other extensions like jpg/gif.

SHGetFolderPath

This code works for windows 7
but doesn't work for windows XP (outputs only part of startup folder path)
#include <iostream>
#include <shlobj.h>
using namespace std;
int main()
{
wchar_t startupFolder[1024];
HRESULT hr = SHGetFolderPath(0, CSIDL_STARTUP, 0, 0, startupFolder);
if (SUCCEEDED(hr))
wcout << L"Startup folder = " << startupFolder << endl;
else
cout << "Error when getting startup folder\n";
getchar();
return 0;
}
output is:
Startup folder = C:\Documents and Settings\Admin\ <- cursor is here.
Newline is not provided.
Also I have russian window xp. I think this is unicode issue.
when I use wprintf I got:
C:\Documents and Settings\Admin\???????? .....
Thanks.
The problem is that the font that your XP console uses does not contain glyphs for the Russian characters you are trying to output. The fonts that Windows 7 ships with and uses by default in its console do have a much broader coverage of Unicode code points. You'll need to configure your console to use a font that contains the glyphs you want.

Resources