Skip to content

Commit

Permalink
Merge pull request #1438 from madeline-underwood/OpenCV_WoA
Browse files Browse the repository at this point in the history
OpenCV_WoA_AP to review
  • Loading branch information
pareenaverma authored Dec 20, 2024
2 parents eff37ec + 82f5bb7 commit bb52d18
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,33 @@ layout: learningpathall

## What is OpenCV?

OpenCV (Open Source Computer Vision Library) is a popular, open-source library that developers use to build computer vision applications. It provides a set of tools and functions that help you handle tasks related to images and videos without needing to write everything from scratch.
Open Source Computer Vision Library (OpenCV) is a popular, Open Source library that developers can use to build computer vision applications. It provides a set of tools and functions that can help you with tasks handling images and videos.

Here’s what developers should know:
Here are some of the benefits of using OpenCV:

* __Ease of Use__: OpenCV comes with pre-built functions for common tasks like reading, displaying, and processing images and videos. This saves time compared to writing algorithms from the ground up.
* __Ease of Use__: OpenCV comes with pre-built functions for common tasks such as reading, displaying, and processing images and videos. This saves time compared to needing to cover absolutely every detail when writing an algorithm.

* __Image Processing__: You can perform operations like changing colors, applying filters, resizing, rotating, and other transformations to images with minimal code.
* __Image Processing__: You can perform operations such as changing colors, applying filters, resizing, rotating, and make other transformations to images with minimal coding effort.

* __Video Handling__: Developers can use OpenCV to capture, modify, and analyze video frames, making it ideal for creating applications like video surveillance or video editing tools.
* __Video Handling__: Developers can use OpenCV to capture, modify, and analyze video frames, making it ideal for creating applications such as video surveillance or video editing tools.

* __Computer Vision Algorithms__: OpenCV includes built-in algorithms for complex tasks like object detection (e.g., face and eye recognition), edge detection, and image segmentation.
* __Computer Vision Algorithms__: OpenCV includes built-in algorithms for complex tasks such as:

* __Machine Learning__: It includes modules for training models using basic machine learning algorithms, which can be applied for pattern recognition and data analysis in visual data.
* Object detection; for example, face and eye recognition.
* Edge detection.
* Image segmentation.

* __Community and Resources__: Being open-source and widely adopted, there is a large community of developers contributing to and supporting OpenCV. This makes it easier to find tutorials, documentation, and answers to questions.
* __Machine Learning__: OpenCV includes modules for training models using basic machine learning algorithms, which can be applied for pattern recognition and data analysis in visual data.

* __Community and Resources__: As OpenCV is Open Source and widely adopted, there is a large community of developers both contributing to, and supporting, OpenCV. This makes it easier to find tutorials, documentation, and answers to questions, as there are many resources available.

## Which compilers are available for Windows on Arm Development?

MSVC (Microsoft Visual C++) and Clang are options for developers building Windows on Arm applications.

* __MSVC__: A compiler developed by Microsoft that’s part of the Visual Studio IDE. It’s designed specifically for Windows and integrates well with the Windows development ecosystem.

* __Clang__: An open-source compiler that is part of the LLVM project. It’s known for its modern design and cross-platform capabilities.

MSVC is ideal for Windows-focused projects needing seamless integration with Visual Studio. Clang is ideal for cross-platform projects or when using modern C++ features.

## Before you begin

Any Windows on Arm machine which has the required tools installed can be used for this Learning Path. You will learn how to build OpenCV using both MSVC and Clang.

Please install the following tools required for both methods.

* [CMake](/install-guides/cmake)

{{% notice Note %}}
The instructions were tested with the version 3.28.1
{{% /notice %}}

* [Git](https://git-scm.com/downloads/win)

{{% notice Note %}}
There is currently no Arm version of Git. Install the 64-bit x86 version.
{{% /notice %}}

Follow the link to install the required tools for a method using MSVC.

* [Visual Studio 2022 or higher](/install-guides/vs-woa).

{{% notice Note %}}
The instructions were tested with Visual Studio 2022.
{{% /notice %}}

To build using Clang, please install the following.

* [LLVM](/install-guides/llvm-woa/)
## Which compilers are available for Windows on Arm Development?

{{% notice Note %}}
The instructions were tested with the version 18.1.8.
{{% /notice %}}
MSVC (Microsoft Visual C++) and Clang are both compilers that are available for developers building Windows on Arm applications.

* [Ninja]( https://github.com/ninja-build/ninja/releases)
* __MSVC__: Developed by Microsoft, MSVC is a compiler that is part of the Visual Studio IDE. It is designed specifically for Windows, and integrates well with the Windows development ecosystem. MSVC is ideal for Windows-focused projects requiring seamless integration with Visual Studio.

{{% notice Note %}}
The instructions were tested with version 1.11.1
{{% /notice %}}
* __Clang__: Part of the LLVM project, Clang is an Open Source compiler that is known for its modern design and cross-platform capabilities. Clang is better suited to cross-platform projects, or when using modern C++ features.

Make sure LLVM Clang and Ninja are in your search path. If they are not, you can use Windows Control Panel to set the PATH environment variable.

You now have the required development tools installed. Please proceed to the page for the compiler you want to build with.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Setup
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---
## Before you begin

You can use any Windows on Arm machine that has the required tools for this Learning Path.

The Learning Path shows you how to build OpenCV using MSVC or Clang.

Click on the links below for the tools download instructions.

### For both compilers

* [CMake](/install-guides/cmake).

{{% notice Note %}}
This Learning Path was tested with CMake version 3.28.1.
{{% /notice %}}

* [Git for Windows on Arm](/install-guides/git-woa).

### For MSVC

Follow the link to install the required tools for a method using MSVC.

* [Visual Studio 2022 or higher](/install-guides/vs-woa).

{{% notice Note %}}
The instructions were tested with Visual Studio 2022.
{{% /notice %}}

### For Clang

To build using Clang, install the following tools:

* [LLVM](/install-guides/llvm-woa/).

{{% notice Note %}}
This Learning Path was tested with LLVM version 18.1.8.
{{% /notice %}}

* [Ninja]( https://github.com/ninja-build/ninja/releases).

{{% notice Note %}}
This Learning Path was tested with Ninja version 1.11.1.
{{% /notice %}}

Make sure LLVM Clang and Ninja are in your search path. If they are not, you can use Windows Control Panel to set the `path` environment variable.

You now have the required development tools installed. You can move on to the page for the compiler that you want to build with.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Build OpenCV Applications with MSVC
weight: 3
weight: 5

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## How do I build OpenCV with MSVC?

Follow the steps below to build OpenCV and a test application using the library with the MSVC compiler.
Follow these steps to build OpenCV and a test application using the library with the MSVC compiler.

### Clone the OpenCV repository

Expand All @@ -21,14 +21,14 @@ git checkout tags/4.10.0
```

{{% notice Note %}}
You might be able to use a later version, but these steps have been tested with the version 4.10.0.
You might be able to use a later version, but these steps have been tested with version 4.10.0.
{{% /notice %}}

### Pre-build configuration

You can use CMake from the command line.

First, run the following command to run the pre-build configuration.
First, run the following command to run the pre-build configuration:

```bash
mkdir build_msvc
Expand All @@ -51,7 +51,7 @@ cmake `
-DWITH_CAROTENE=OFF
```

The given options specify the following:
The given options in the code above specify the following:
- The source code is located one level above the current directory.
- The build will be performed in the current directory.
- The Visual Studio 2022 MSVC compiler will be used as the compiler.
Expand Down Expand Up @@ -108,12 +108,12 @@ cmake --build . --target INSTALL --config Release
```

{{% notice Note %}}
The build takes approximately 25 mins on a Lenovo X13s
The build takes approximately 25 mins on a Lenovo X13s.
{{% /notice %}}

 

When the build and the install steps are complete, confirm the shared library has been created by inspecting the results in the `install/bin` directory:
When you have completed the build and installation steps, confirm the shared library has been created by inspecting the results in the `install/bin` directory:

```bash { output_lines = "2-12" }
ls ./install/x64/vc17/bin
Expand Down Expand Up @@ -148,15 +148,15 @@ Mode LastWriteTime Length Name

The library used in your application is `opencv_world<version>.lib/dll`.

Once the library files are correctly generated, run the following command to ensure there are no errors.
Once the library files are correctly generated, run the following command to ensure that there are no errors.

```bash { output_lines = "2" }
./install/x64/vc17/bin/opencv_version.exe
4.10.0
```

{{% notice Note %}}
The genereated directory name contains "x64," but there is no need to worry as the libraries and executable files will definitely run as ARM64.
The generated directory name contains "x64," but there is no need to worry as the libraries and executable files will definitely run as AArch64.
{{% /notice %}}

&nbsp;
Expand All @@ -169,23 +169,23 @@ Once the OpenCV library has been successfully created, the next step is to link

First, create a new project in Visual Studio.

Launch Visual Studio, click `Create a new project` on the initial screen, then select `Empty Project` and click `Next`.
Launch Visual Studio, click **Create a new project** on the initial screen, then select **Empty Project**, and click **Next**.

On the next screen, set the `Project name` and `Location`. You can choose any name and location, but for this example, name the project `TestOpenCV`, as shown below.
On the next screen, set the **Project name** and **Location**. You can choose any name and location, but for this example, name the project `TestOpenCV`, as shown below.

Click `Create` to generate the new project.
Click **Create** to generate the new project.

![MSVC project #center](msvc_project.png "Create a new project")

### Add source code

In `Solution Explorer`, right-click the `Source Files` folder, select `Add`, and then `New Item...`. Create a file named `test_opencv.cpp`.
In **Solution Explorer**, right-click the **Source Files** folder, select **Add**, and then **New Item...**. Create a file named `test_opencv.cpp`.

![MSVC add file #center](msvc_add_file.png "Add a source file")

&nbsp;

Once the file is created, it will open in the editor.
Once the file is created, it opens in the editor.

Copy and paste the following program into it and save the file.

Expand All @@ -205,17 +205,25 @@ int main() {
}
```

This program is a simple example that uses OpenCV to create a 100x100 black image, draw a blue circle on it, and save it as a file.
This program is a simple example that uses OpenCV to do the following:

* Create a 100x100 black image.
* Draw a blue circle on it.
* Save it as a file.

### Configure build settings

Next, select the `Configuration` dropdown menu in the center of the screen and change it from `Debug` to `Release`. At this stage, your screen should look like the example shown below.
Next, select the **Configuration** drop-down menu in the center of the screen, and change it from **Debug** to **Release**. At this stage, your screen should look like the example shown below.

![MSVC screenshot #center](msvc_screen.png "MSVC screenshot")

&nbsp;

Now, set up the compile and link settings. Select `Project` from the top menu and click on `TestOpenCV properties`. Edit `Include directories`, `Library directories`, and `Additional dependencies` as shown in the images below, and then click OK.
Now, set up the compile and link settings.

Select **Project** from the top menu and click on **TestOpenCV properties**.

Edit **Include directories**, **Library directories**, and **Additional dependencies** as shown in the images below, and then click **OK**.

![MSVC include dir #center](msvc_include_dir.png "Include directories: Specify the directory containing the OpenCV header files.")

Expand All @@ -237,7 +245,7 @@ Finally, ensure that the directory containing the dynamic libraries (DLLs) is ad

You are now ready to build the application.

From the top menu, select `Debug` and click `Start Without Debugging` or press `Ctrl` + `F5`.
From the top menu, select **Debug** and click **Start Without Debugging** or press Ctrl+F5.

If a console window appears showing that the program exited with code 0 and `test_image.png` is generated in the top-level directory of your Visual Studio project, you have succeeded.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Once the library files are correctly generated, run the following command to ens

Once the OpenCV library has been successfully created, you can create a simple application and try using it.

### Prepare a application program
### Prepare an application program

First, use a text editor to save the following C++ program as `test_opencv.cpp` in the `build_clang` directory.

Expand Down Expand Up @@ -216,7 +216,7 @@ Run the test program:
.\test_opencv.exe
```

When you execute the command, it will finish quickly, and `test_image.png` is generated. If you don't have the DLL directory in your search path, the program appears to run, but no `test_image.png` is generated.
When you execute the command, it will finish quickly, and `test_image.png` is generated. If you do not have the DLL directory in your search path, the program appears to run, but no `test_image.png` is generated.

Open the image file, it should look like the example shown below.

Expand Down
10 changes: 4 additions & 6 deletions content/learning-paths/laptops-and-desktops/win-opencv/_index.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
---
title: Build OpenCV applications on Windows on Arm
draft: true
cascade:
draft: true
title: Create OpenCV applications on Windows on Arm

minutes_to_complete: 90

who_is_this_for: This is an advanced topic for software developers who want to use OpenCV with Windows on Arm devices.
who_is_this_for: This is an advanced topic for software developers who want to build and develop applications on Windows on Arm devices using OpenCV.

learning_objectives:
- Build the OpenCV library for Windows on Arm devices.
- Develop applications using OpenCV.

prerequisites:
- A Windows on Arm computer such as Lenovo Thinkpad X13s or an [Azure virtual machine](/learning-paths/cross-platform/woa_azure/).
- A Windows on Arm machine such as the Lenovo Thinkpad X13s, or an [Azure virtual machine](/learning-paths/cross-platform/woa_azure/).

author_primary: Koki Mitsunami

Expand Down

0 comments on commit bb52d18

Please sign in to comment.