I downloaded the sources of opencv-2.4.5 and I followed the tutorial (on the opencv site for windows) about the installing my own libraries everything. Ok. I created the opencv.sln file with cmake then I opened it with visual studio 2010 professional and I click the build solution but just 9 succeeded. Most of the 200 failed and most of the errors about tbbd.lib not found and opencv_core245d.lib not found with LNK1104 error. I'm trying to solve it for how many days. I've tried to show the ways of files... Anyone can help please? This is about my dissertation. (Build with No Common Language Support)
Collapse
I spent a good 15 hours or so to get the homework finished using OpenCV. 14.5 of those hours were spent just getting it setup properly. I ran through about 7 tutorial videos, several set up guides, and read hundreds of posts containing resolutions to the same erros I was getting.So I understand that simply installing OpenCV is not a trivial task and there are several steps to do this. So here is a straightforward tutorial for setting it up if you want to use openCV.
It is important to understand how things work as far as linking goes. There are three types of files, your headers that you include, the .dlls that contain the functions, and the libraries that contain instructions for how to call the functions in the .dlls. So here, rather than add just the .dlls as dependencies in the input linker, we are going to add the lib files. We will then create a System Environment variable that will tell the machine where to look for the .dll files when their corresponding library files are referenced. We will be creating a Property Sheet so that when we create a new project, we can simply add the settings to our project by clicking "Add Existing Property Sheet" instead of adding a new one. This way, we never have to go through this again.
FOLLOW THESE STEPS EXACTLY AND MAKE SURE VISUAL STUDIO IS CLOSED BEFORE CONTINUING
NOTE: When text is given in quotes with instructions to copy said text, do not include the quotes.
First of all, the easy part - download OpenCV 2.4.5 from their website. http://opencv.org/ and click OpenCV for Windows. It will download OpenCV 2.4.5.exe.
Install OpenCV
When the download finishes, double click OpenCV-2.4.5.exe to run it.
When asked where to extract the files, type ino the text box: "C:\"
C:\opencv should have been created upon completion. Navigate there to make sure.
Setup Environment Variables
WINDOWS 8 USERS:
- Right click the bottom left corner of your screen when the start icon pops up.
- Click "Command Prompt (Admin)"
- Type "SETX -m OPENCV_DIR C:\opencv\build" and press enter to set the opencv build directory as a System Environment Variable. Wait for the console to give you confirmation that it is set.
- Right click the bottom left corner of your screen when the "Start" icon pops up. Click System -> Advanced System Settings -> Environment Variables
- In the "System Variables" list box, under the "Variable" collumn, find "Path".
- Highlight the "Path" row and click edit.
- Click in the "Variable Value" text box and hit the "end" key on your keyboard to scroll to the end of the line and add a semicolon.
- Type the following: "C:\opencv\build\x86\vc10\bin;C:\opencv\build\x86\vc10" and click "OK". This will add the openCV bin directory to the system path.
WINDOWS 7 USERS:
Follow the same steps. The only difference is how you get to the command prompt and the system settings. Google how to set up an environment variable on Windows 7 if needed.
Setup Visial Studio
NOTE: I highly recommend VS2012 Professional because of advanced syntax highlighting that makes life so much easier when programming C++. This version can be downloaded and installed for free from DreamSpark. Just make and account with your student ID. However, the steps for VS2010 and VS2012 are the same.
Open Visual Studio
Click "New Project" and under "C++" select "Win32 Console Application".
When the window opens click "Next", check "Empty Project", and click "Finish". It is very important that you start with an EMPTY PROJECT without a precompiled header.
Locate the "Property Manager." By default, it should be a tab that is sometimes hard to miss. Alternatively it can be accessed by clicking from the toolbar "View" -> "Property Manager".
Right Click "Debug | Win32" and select "Add New Project Property Sheet". Name it "OpenCVProps" and click "Add".
Right Click your new property sheet and select "Properties".
From the left column, go to "C/C++" -> "General" and in the listbox on the right, select "Additional Include Directories" and click "Edit".
Add the following THREE directories:
"$(OPENCV_DIR)\include"
"$(OPENCV_DIR)\include\opencv"
"$(OPENCV_DIR)\include\opencv2"
From the left column, go to "Linker" -> "General" and in the listbox on the right, select "Additional Library Directories" and click "Edit".
Add the following directory:
"$(OPENCV_DIR)\x86\vc10\lib"
From the left column, go to "Linker" -> "Input" and in the listbox on the right, select "Additional Dependenies" and click "Edit".
Add the following .lib files to the depedencies. You may do this by copying and pasting these into that edit box. I have purposely not included a bulletpoint to make it easy for you to copy paste these.
opencv_core245d.lib
opencv_imgproc245d.lib
opencv_highgui245d.lib
opencv_ml245d.lib
opencv_video245d.lib
opencv_features2d245d.lib
opencv_calib3d245d.lib
opencv_objdetect245d.lib
opencv_contrib245d.lib
opencv_legacy245d.lib
opencv_flann245d.lib
NOTE: If building for release, these steps are the same. However, when copying and pasting these files, remove the 'd' from the end of each of them. The 'd' denotes that it is a release library and links to a release .dll.
Congrats! The difficult part is almost done! Click "OK" to close the Window.
Creating and Building a Test Project
Head over to our Solution Explorer. This can be focused from the toolbar via "View" -> "Solution Explorer"
Right click "Source Files" and select "Add" -> "New Item".
Select "C++ File (.cpp)" and name the file "main.cpp". Click "Add".
Copy and paste the following program and press "F7" on your keyboard and watch the bottom left corner of your screen to see if you get a "Build Succeeded" message. If so, only one step left before you compile and run! If not, please retrace your steps, or comment below and maybe I can help.
#include <opencv\cv.h>
#include <opencv\highgui.h>
int main(int argc, char* argv)
{ // openCV .image object
cv::Mat inputImage;
//Create a Window
cv::namedWindow("window",1);
// Initialize our image.
inputImage = cv::imread("Lenna.png");
// Always check to make sure that image has data.
if(inputImage.empty())
{
std::cout << "Image Failed to Load.";
return -1;
}
else
{
// All is well, display me.
cv::imshow("window",inputImage);
// Wait for user to press a key to exit.
cvWaitKey(0);
}
return 0;
}
If the build succeeded, then all that is left is to add the image to your folder. The placement is very important. I have copied the directoy that I have placed mine in. Follow the same directory pattern.
"C:\Users\Josh\Documents\Visual Studio 2012\Projects\ConsoleApplication3\ConsoleApplication3\Lenna.png"
Now hit "Ctrl + F5" To build, compile, and run to observe your image in the window!!
*IF YOU HAVE A WEBCAM*
Copy and paste the following code to check if OpenCV is working without being required to add an image. This is useful because if the above code doesn't work, but this code does, then you know you put the image in the wrong folder.
#include
#include
int main(int argc, char* argv)
{ // openCV .image object
cv::Mat image;
//Create a Window
cv::namedWindow("window",1);
// Create the capture object.
cv::VideoCapture device;
// Open your webcam.
device.open(0);
while (1)
{
// Read data from your device and store it to the image frame.
device >> image;
// Always check to make sure that image has data.
if(image.empty())
{
std::cout<< "Image Failed to Load.";
return -1;
}
else
{
// All is well, display me.
cv::imshow("window",image);
// Wait for user to press a key to exit.
cvWaitKey(33);
}
}
return 0;
}
Happy Coding!! Let me know if something didn't work so I can fix it!
Quick Answer
I have managed to compile OpenCV with TBB support using the tutorial here.
Specs: Visual Studio 2012/ Win 7 (64 bit)/ OpenCV 2.4.5/ CUDA 5
I have downloaded the latest TBB zip and extracted it to C:/src/OpenCV/dep (as suggested in the tutorial linked above).
You have to use the following TBB settings in CMake (adapt depending on your file paths):
TBB_LIB_DIR :: C:/src/OpenCV/dep/tbb41_20130314oss/lib/intel64/vc11
TBB_INCLUDE_DIRS :: C:/src/OpenCV/dep/tbb41_20130314oss/include/
TBB_STDDEF_PATH :: C:/src/OpenCV/dep/tbb41_20130314oss/include/tbb/tbb_stddef.h
WITH_TBB :: checked
BUILD_TBB :: unchecked
More Information
Initially, I also wanted to install OpenCV with CUDA 5 support, but it seems that CUDA 5 is incompatible with VS2012. This is the error I got when compiling
OpenCV:
Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/Debug/cuda_compile_generated_matrix_operations.cu.obj
nvcc : fatal error : nvcc cannot find a supported cl version. Only MSVC 9.0 and MSVC 10.0 are supported
The good news is that you are using VS2010, which can be used with CUDA, as suggested here.
VS2012 can be set up to create projects with CUDA, but there is currently no way (AFAIK) to compile OpenCV with CUDA support for VS2012 (read this for more info).
In conclusion, people that need CUDA support should compile and use OpenCV with VS2010.
Also, when compiling OpenCV, I got the following errors:
error C3859: virtual memory range for PCH exceeded; please recompile with a command line option of '-Zm118' or greater
fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
I used the instructions here to finally compile OpenCV. I created a Property Sheet which had /Zm130 as an additional option in Common Properties > C/C++ > Command Line and added it
to all of the generated OpenCV projects.
For your reference, I also attach the CMake configuration and CMakeCache.txt file that I've used (CUDA is disabled as I am using VS2012):
CMake configuration: http://pastebin.com/8rJZGZ3T
CMakeCache.txt: http://pastebin.com/A0q8YgJg
Hope this helps and please comment if you need me to elaborate on any step.
I installed again opencv-master, opencv-2.4.5 and opencv-2.4.7 both to my new laptop. OpenCV-2.4.7's imread function returned always null but C-cvImageLoad worked well and opencv-master's cvLoadImage didn't work cvImageLoad or I missed something. But TBB's dir must be .../bin/ia32 not intel64 my OS is 64-bit but VS201x 32-bit this was my error. And I've get stitching and gpu errors and visual studio is telling about the error and this is usually memory allocation limit error and I did same things like your said #dilgenter and now it's working well but just 2.4.5 well and the python_d.lib error can be occur this is not a problem at debug mode I've read about this from a lot of forum sites. I'll try to find why 2.4.7's imread returning null Mat element. But now I'm too busy and this is
Related
In Notepad++, view Settings > Shortcut Mapper > Scintilla commands. The command SCI_LINECOPY, currently assigned to Ctrl + Shift + X, copies the current line to the clipboard for pasting elsewhere. Very nice!
Does Visual Studio 2019 have something similar under Tools > Options > Environment > Keyboard? The Edit.Duplicate command, which copies the current line into the editor though not to the clipboard, is excellent but only superficially similar to SCI_LINECOPY.
For me, without any additional adjustment, this is a normal process as shown in the pictures below.
When the cursor is in the line (1), I can copy it to the clipboard without selecting the text first using Strg+C.
Followed of course by Strg+V (2) or optional by step (3).
installing some libraries like opencv is hard unfair game with this level:(but it's seems easy when you are watching youtube:) )
Error 1 : strcpy_s and strcat_s are not declared in this namespace. To resolve it use the function strncpy and strncat respectively. The format of latter is different from previous one.
strncpy( szKey, icvWindowPosRootKey, 1024 );
strncat( szKey, name, 1024 );
Error 2 : time was not found in this scope.
Error 3 :modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:146: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj' failed
Error 4 : recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
mingw32-make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all
Error 5 :recipe for target 'all' failed
Error 6 : ‘M_PI’ was not declared in this scope
Error 7 : ‘posix_memalign’ was not declared in this scope
Error 8 :‘D3D11_TEXTURE2D_DESC’ was not declared in this scope
Error 9 :opencv 'nullptr' was not declared in this scope
Error 10 : 'mutex' in namespace 'std' does not name a type
Error 11 :expected unqualified-id before '>' token
Error 12 :limpc-3.dll was not found opencv
Error 13 :recipe for target pch_Generate_opencv_core.dir/all' failed
Error 14 :'modules/core/precomp.hpp.gch/opencv_core_Release.gch' failed opencv 4
fallow these 2 tutorials if have some problems with opencv and test different vertion of mingw cmake and codeblock :
https://blog.faltutech.com/2018/c-plus-plus-c/09/03/compile-and-integrate-opencv-3-4-1-into-codeblocks-17-12-with-gcc-5-1-0/#
https://blog.huihut.com/2018/07/31/CompiledOpenCVWithMinGW64/
second tutorials is more important(blog.huihut.com)
:::::
(this is first tutorials)
Needed Tools:
OpenCv 3.4.1 Windows self-extracting archive Download
CodeBlocks 17.12 Without Mingw Download
Cmake 3.12 .msi Download
TDM-GCC-64 (tdm64-gcc-5.1.0-2.exe) Download //i use this vertion :x86_64-5.3.0-release-posix-seh-rt_v4-rev0
Common Sense Download 🙂
Steps:
Install and open Cmake
Download and Extract Opencv (exe is a type of package. It will ask you the path when you open the opencv.exe) in directory c:\Opencv
Create new directory “opencv_codeblocks” in C:\opencv
Download and Install TDM-GCC-64 in directory C:\TDM-GCC-64 and add the path “C:\TDM-GCC-64\bin” to the environment variables. Watch below video to know how to add the the path to environment variables.
Open CMake.
Select path “C:/Opencv/opencv/sources” in Option Where is the source code
Select path “C:/Opencv/Opencv_codeblocks” in Option Where to build the binaries. These are same folder we have created earlier.
Click Build.
Now you will see some options in table like structure. Few will be checked and few are not. So make sure about these four :
PRECOMPILED _HEADERS : Uncheked
MFMS : Unchecked
IPP : Unchecked
Builed Opencv world : Checked
Click build again and after that click generate.
Now in directory Opencv_codeblocks a codeblock project file will be created with extension cbp. Double click on it.
Before building we have to configure Codeblocks.
Go to Settings->compiler
From Drop Down Select GNU GCC Compiler
Select option Toolchain executables
In option compiler’s installation directory choose the path “C:\TDM-GCC-64” Which is the path of installation of GCC compiler .
Click on Auto Detect. And click on OK in popup.
Go to tab Compiler Flags and Select option “Have g++ follow C++11 ISO C++ language standard [-std=c++11]”
Click OK
Now From Build option in menu bar click on Build. Or See for following symbols.
There Will Few Errors those will be shown while building :
Error 1 : strcpy_s and strcat_s are not declared in this namespace. To resolve it use the function strncpy and strncat respectively. The format of latter is different from previous one.
strncpy( szKey, icvWindowPosRootKey, 1024 );
strncat( szKey, name, 1024 );
The Error1 will be shown 4 or 5 times. So change the functions to the equivalents. Save the changes each time using Ctrl+s and click build every time you make changes to files.
Error2 : time was not found in this scope. So resolve it add header file time.h (#include )to the file top in which the error is shown. Save and Click Build again.
Go to : Build->Select Target and select “install” option.
Click Build option Again. The above process will take some time. On Successful build continue to following steps. Otherwise try to remove them if you can.
Do Some copying :
Copy opencv and opencv2 folders from “C:\opencv\build_codeblocks\install\include” to “C:\TDM-GCC-64\x86_64-w64-mingw32\include”
Copy libopencv_world343.dll.a (number 343 can change with new release of Opencv) from “C:\opencv\build_codeblocks\install\x64\mingw\lib” to “C:\TDM-GCC-64\x86_64-w64-mingw32\lib”
Copy Everything from “C:\opencv\build_codeblocks\install\x64\mingw\bin” to “C:\TDM-GCC-64\bin”
Now create a new project in codeblocks and write your code with the inclusion of required header files by your code (Read Documents of OpenCV). example code :
#include <opencv2/core/core.hpp> //additional space in header address could cause "not found" problems
#include <opencv2/highgui.hpp >
#include <iostream>
using namespace cv;
using namespace std;
int main() {
Mat image1, image2;
image1 = imread("cross.png", CV_LOAD_IMAGE_COLOR);
if (!image1.data) {
cout << "could not find image1" << endl;
}
image2 = imread("cross.png", CV_LOAD_IMAGE_GRAYSCALE);
if (!image2.data) {
cout << "could not find image2" << endl;
}
cout << "opencv test" << endl;
namedWindow("Color Image", WINDOW_AUTOSIZE);
imshow("Color Image", image1);
namedWindow("Gray Scale Image", WINDOW_AUTOSIZE);
imshow("GRAY Scale Image", image2);
waitKey(0);
destroyAllWindows();
return 0;
}
Before building right click on project in left side pane and select build options.
Go to linker settings and click Add.
Write “opencv_world343” in input box and click ok. Note that 343 can change as said above. So 343 should same as the file you copied above.
Now you can build and run the code.//you can also add opencv lib and include folder in search directory like me
If you do not have to code in C++, you can install OpenCV in your Python environment using pip install opencv-python or pip install opencv-contrib-python if you also want contib module. The detailed information is here. You may also use Anaconda for installing OpenCV with command conda install -c conda-forge opencv. In my opinion, using Anaconda makes things a lot easier and I recommend it.
I am facing a problem with my visual studio 2013 ultimate. i would run a open cv project but iam getting a error message like this " opencv_core249d.lib" missing from ur computer. re install the program.
Solution : It works with eclipse Version: Mars.2 Release (4.5.2).
This is a missing .dll issue, not a missing lib issue. It usually occurs when the Environment Variables have not been correctly set in your Windows environment. To take care of this problem, there are 2 methods:
1) edit Environment variables
Go to ‘My Computer’ , right-click and select ‘Properties’. A window called ‘System’ will open, containing the Windows Logo on the right. On the left margin of this window, you will find a link named ‘Advance system
settings’. Click on it.
Another window called ’System Properties’ will open. On the bottom right corner of this window, click on the button named ’Environment Variables..’.
Under the ‘System variables’ column, look for a variable by the name ‘Path’. - Select ‘Path’ and click ‘Edit..’
In the ‘variable value’ row, add the following address:
\path to\opencv\build\x86\vc12\bin;
Please Note- Ensure that the new address added by you, and the address previously written in the ‘variable value’ row, are separated by a ; DO NOT REMOVE the previous environment variable addresses.
2) Manually copy the .dll files.
In case the first approach does not work for you, go to:
\path to\opencv\build\x86\vc12\bin;
You'll find all the dll files that you're looking for. Copy those files to directory where your source code is located.
This is what happened. We downloaded Quickreports 505, installed it, but had to revert to QR504. Now we are getting
[BCC32 Warning] W8123 Path 'C:\Program Files\Embarcadero\RAD Studio\8.0\Quickrep505C' not found - path ignored in option '-I'
This question has been asked on both Embarcadero, and quick report forums but all of their answers has been modify the cbproj file, which do not contain any references to quickreports.
I've tried removing all the references from the IDE but the warning still occurs. Any suggestions on how to fix what should be a simple problem.
Sources:
https://forums.embarcadero.com/thread.jspa?messageID=486503
http://forum.quickreport.co.uk/default.aspx?g=posts&t=1675
Using:
IDE: C++BuilderXE
Note I do not want to disable all warnings in the IDE, and I don't want to disable warnings in Code.
I've had the same annoying problem. To fix this I had to delete all reference to the file in the EnvOptions.proj file. This file is located in the ...AppData\Roaming\Embarcadero\BDS\8.0\ folder.
I got rid of this in my XE7 IDE directly via:
Tools > Options > Environment Options > C++ Options > Path and Directories.
There were invalid paths to libraries being referenced and showing up as warnings in the build. Select each of the ... icons to explore the list of paths included, and select Delete Invalid Paths to remove unused paths.
To enhance and update prior answers, this is what I had to do...
From the menus: [Tools] [Options]
In the Dialog box: [Environment Options] [C++ Options] [Paths and Directories]
Now at the top on the right side in the drop down pick: [32-bit Windows] (it started as Android)
The clear invalid paths in both tabs [Compiler] & [Classic Compiler]
Remove Warning Message File Path Not Found
[BCC32 Warning] W8123 Path 'C:.....' not found - path ignored in option '-I'
Version 10.4.2 Sydney
========
In IDE Right Click on Executable
Options...
C++ Compiler->Directories and Conditionals
Include file search path > (Double click)
then click on
Value from "All configurations - All platforms"
Click on ... in right hand side in text edit box on right hand side
Click on down arrow beside button "Tasks"
Delete Invalid Paths
"Save"
I have this project that I sometimes work at at the office and sometimes at home. And the paths of the external files are not the same on both computers, so I added them both in the folder lists.
Is there another way to supress these warnings without having to remove "invalid" paths from the folder lists?
Edit:
I thought I found the answer, but this setting doesn't work
Am a beginner to OpenCV and have gone so far as to work out the hello world samples, inverting, color conversion(RGB->greyscale ) etc programs working.
However i am stuck at the Programs that use cvCanny, cvPyr and other such feature detectors.Would really be thankful if the tiny prblem was sorted out .
I get the Error: error C3861: 'cvPyrDown': identifier not found
error C3861: 'cvCanny': identifier not found
I've included the imgproc and features2d headers yet the problem persists.
What am I missing out ?
Do you have your "Additional input directories" property set correctly?
Mine, configured by cmake, looks like this:
C:/OpenCV-2.2.0/release
C:/OpenCV-2.2.0/include
C:/OpenCV-2.2.0/include/opencv
C:/OpenCV-2.2.0/modules/core/include
C:/OpenCV-2.2.0/modules/imgproc/include
C:/OpenCV-2.2.0/modules/features2d/include
C:/OpenCV-2.2.0/modules/gpu/include
C:/OpenCV-2.2.0/modules/calib3d/include
C:/OpenCV-2.2.0/modules/objdetect/include
C:/OpenCV-2.2.0/modules/video/include
C:/OpenCV-2.2.0/modules/highgui/include
C:/OpenCV-2.2.0/modules/ml/include
C:/OpenCV-2.2.0/modules/legacy/include
C:/OpenCV-2.2.0/modules/contrib/include
C:/OpenCV-2.2.0/modules/flann/include
Btw. CMake is a nice tool if you are dealing with libraries that contains many include files, line OpenCV.
You can also check two other things:
After compiling OpenCV2.2 from sources, did you built "INSTALL" project in the OpenCV VS solution?
If you are using c++ headers, you might prefer c++ version of those functions,
in the cv namespace:
cv::Canny(...)
That sounds like a link error rather than any problems with include. Are you sure you are linking with cv.lib?
You need to add the $(OPENCV_ROOT)/lib directory to the linker path so it knows where to search for the files.
From the description, I assume you're using Visual Studio? If so, you have two options for doing so.
Add it to this project under Project -> Properties -> Linker -> General -> Additional Library Directories.
Add it for all projects: Tools -> Options -> Projects and Solutions -> VC++ Directories -> Library files. And then add folders there.