I wonder if opencv has been installed

Hi,
I went to git hub and downloaded the latest opencv .exe file and then ran the file.
it appears to have installed.

There is a location where I think files were placed under my suer directory
C:\Users\G\openCV\opencv\build\include\opencv2

Several directories are there. My goal is to create a C++ program that will display an image.

So I also downloaded the community edition of visual studio. And I do have C++ Builder available that is my goto C++ Compiler.

I was looking for the Visual C++ Solution mentioned in a Youtube video but I don’t see it.

Thank You,
Gary

borland/embarcadero, right?

that’s the wrong compiler.

the official OpenCV library binaries for C++, on Windows, are for MSVC/Visual Studio only.

youtube videos on this topic are usually junk. if you do follow them, be aware that everything could be bad advice. be critical of everything they say or do there.

you can set up a VS solution/project yourself. that requires setting some paths and listing the modules of opencv that you want to use (core, imgcodecs, imgproc, highgui, and so on). this is not much work. if you aren’t familiar with C++ on the level of telling your toolchain where to find libraries and to link them to your program, then this will require learning about this general development task as well.

or use CMake with a minimal cmakelists.txt for your project. CMake is supposed to be able to find OpenCV on your system. this step might need some manual intervention.

remember that the official binaries already give you a compiled OpenCV. you don’t need to build opencv yourself (if you use MSVC/Visual Studio). you only need to build your own program code to use OpenCV.

I tried to run opencv using Visual Studio on Windows 11. But it is missing many include files. I think I was missing some steps during the installation process. For instance if I go look for
opencv2/include there is only one include file located in the directory. that file has the name,
opencv.hpp

the location of that file is placed under the C drive.

full path is

C:\opencv\sources\include\opencv2

The bin directory is also under opencv as I would have expected.

I think I should have done done something with the Contribution area but I did not install it.

Any help is greatly appreciated.

Thank You,
Gary

wrong file. as a user of the library, nothing in “sources” is relevant to you. that’s for building the library, not for using it.

look for an “install” directory. that is where you find what you need.

chatGPT assisted instruction

:white_check_mark: How to Compile OpenCV from Source (Windows, Minimal Version)

Step 1: Install Required Tools

:white_check_mark: Make sure git, cmake, and python are added to your system PATH.


Step 2: Clone the OpenCV Repository

Open Command Prompt or PowerShell and run:

bash

CopyEdit

git clone --depth=1 https://github.com/opencv/opencv.git

Step 3: Create Build Directory and Run CMake

bash

CopyEdit

cd opencv
mkdir build-opencv
cd build-opencv
cmake ..

:warning: If you want Python bindings or specific modules, you should pass options to cmake, like:

bash

CopyEdit

cmake -DBUILD_opencv_python3=ON -DCMAKE_INSTALL_PREFIX=install ..

Step 4: Build OpenCV

bash

CopyEdit

cmake --build . --config Release

:memo: This step will take several minutes depending on your system.


:white_check_mark: Optional: Install OpenCV

bash

CopyEdit

cmake --install . --config Release

This will install OpenCV to the path defined by CMAKE_INSTALL_PREFIX.

That is for building OpenCV itself. I am quite sure that the user doesn’t need that.

you are right but i prefer compiling from source

how to set OpenCV library to Visual Studio

ChatGPT said:

To set up the OpenCV library in Visual Studio (for C++ development), follow these steps:


:white_check_mark: Step-by-step Setup (Windows + Visual Studio)


:brick: 1. Install OpenCV

  • Download prebuilt OpenCV for Windows:
    Releases - OpenCV
  • Extract it to a folder like:
    C:\opencv

You should now have:

makefile

CopyEdit

C:\opencv
 └── build
     ├── include
     ├── x64
     │   └── vc16  (for Visual Studio 2019/2022)
     │       ├── lib
     │       └── bin
     └── etc...

:brain: 2. Set Environment Variable (optional but useful)

  • Open System Properties → Environment Variables.
  • Add:
    • Variable name: OpenCV_DIR
    • Variable value: C:\opencv\build

:laptop: 3. Create/Open Visual Studio Project

  • Open Visual Studio.
  • Create a new Console App (C++).
  • Go to Project → Properties.

:gear: 4. Configure VC++ Directories

For Debug and Release both, under x64 platform:

:file_folder: Include Directories

  • Go to: Configuration Properties → VC++ Directories → Include Directories
  • Add:

makefile

CopyEdit

C:\opencv\build\include

:file_folder: Library Directories

  • Go to: Configuration Properties → VC++ Directories → Library Directories
  • Add:

vbnet

CopyEdit

C:\opencv\build\x64\vc16\lib

:link: 5. Linker Settings

Go to: Configuration Properties → Linker → Input → Additional Dependencies

:plus: Add these libraries (basic setup):

plaintext

CopyEdit

opencv_world490d.lib   // for Debug
opencv_world490.lib    // for Release

Replace 490 with your actual OpenCV version number.


:chequered_flag: 6. Add DLL Path to PATH (or copy DLLs)

You can either:

Option A: Set PATH at runtime

cpp

CopyEdit

SetDllDirectory("C:\\opencv\\build\\x64\\vc16\\bin");

Option B: Copy DLLs to your .exe output folder

From:

makefile

CopyEdit

C:\opencv\build\x64\vc16\bin\

Copy the corresponding .dll files (opencv_world490.dll or opencv_world490d.dll) to your Debug or Release output folder.


:page_facing_up: 7. Test Code

cpp

CopyEdit

#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
    cv::Mat img = cv::imread("test.jpg");
    if (img.empty()) {
        std::cerr << "Image not loaded!" << std::endl;
        return -1;
    }
    cv::imshow("Image", img);
    cv::waitKey(0);
    return 0;
}

:white_check_mark: Done!

Let me know if you’re:

  • Using static linking instead of dynamic (.lib only)
  • Working with OpenCV built from source (CMake)
  • Using multiple modules, like opencv_imgcodecs, opencv_highgui, etc., instead of opencv_world.

i just want to point anyone can use help of AI for getting such informations