You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/win-opencv/1-opencv-compilers.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: OpenCV and Compilers
2
+
title: OpenCV and Compilers for Windows on Arm
3
3
weight: 2
4
4
5
5
### FIXED, DO NOT MODIFY
@@ -30,13 +30,13 @@ When building applications for Windows on Arm, both MSVC (Microsoft Visual C++)
30
30
31
31
*__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.
32
32
33
-
*__Clang__: An open-source compiler that is part of the LLVM project. It’s known for its modern design and and cross-platform capabilities.
33
+
*__Clang__: An open-source compiler that is part of the LLVM project. It’s known for its modern design and cross-platform capabilities.
34
34
35
35
MSVC is the go-to for Windows-focused projects needing seamless integration with Visual Studio. Clang is ideal for cross-platform projects or when using modern C++ features with flexibility.
36
36
37
37
## Before you begin
38
38
39
-
Any Windows on Arm computer which has the required tools installed can be used for this Learning Path. You will learn the build methods using both MSVC and Clang.
39
+
Any Windows on Arm machine which has the required tools installed can be used for this Learning Path. You will learn the build methods using both MSVC and Clang.
40
40
41
41
Please install the following tools required for both methods.
42
42
@@ -76,4 +76,4 @@ The instructions were tested with version 1.11.1
76
76
77
77
You use the LLVM Clang and the Ninja generator to build. Set PATH to the paths to your LLVM and Ninja install.
78
78
79
-
You now have the required development tools installed.Please proceed to the page for the compiler you want to build with.
79
+
You now have the required development tools installed.Please proceed to the page for the compiler you want to build with.
The directory name in the middle is "x64," but there is no need to worry as the generated libraries and executable files will definitely run as ARM64.
135
-
{{% /notice %}}
139
+
140
+
141
+
`opencv_world<version>.lib/dll` will be the library used by your application. Once the library files are correctly generated, run the following command to ensure there are no errors.
136
142
137
143
```bash { output_lines = "2" }
138
-
./install/x64/vc17/bin/pencv_version.exe
144
+
./install/x64/vc17/bin/opencv_version.exe
139
145
4.10.0
140
146
```
141
147
148
+
{{% notice Note %}}
149
+
The genereated directory name contains "x64," but there is no need to worry as the libraries and executable files will definitely run as ARM64.
150
+
{{% /notice %}}
151
+
152
+
153
+
142
154
## Build OpenCV Applications
143
155
156
+
Once the OpenCV library has been successfully built, the next step is to link it to a simple application and try using it.
157
+
158
+
### Create a new project in Visual Studio
159
+
160
+
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`. On the next screen, set the `Project name` and `Location`. You can choose any name and location, but for this example, we named the project `TestOpenCV`, as shown below. Then click `Create` to generate the new project.
161
+
162
+

163
+
164
+
### Adding a source code
144
165
145
-
Add C:\Users\kokmit01\work\opencv\build\install\x64\vc17\bin to PATH environment variable (for access to dll)
146
-
put the dll to the directory with exe file if it doesn't work.
166
+
In `Solution Explorer`, right-click the `Source Files` folder, select `Add`, and then `New Item...`. Create a file named `test_opencv.cpp`.
147
167
148
-
Set include dir/linker path
168
+

149
169
170
+
150
171
172
+
Once the file is created, it will open in the editor. Copy and paste the following program into it and save the file.
151
173
152
174
```cpp
153
175
#include<opencv2/opencv.hpp>
@@ -163,4 +185,43 @@ int main() {
163
185
cv::waitKey(0);
164
186
return 0;
165
187
}
166
-
```
188
+
```
189
+
190
+
This program is a simple example that uses OpenCV's functionality to create a 100x100 black image, draw a blue circle on it, and save it as a file.
191
+
192
+
### Configure build settings
193
+
194
+
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.
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.
201
+
202
+

203
+
204
+
205
+
206
+

207
+
208
+
209
+
210
+

211
+
212
+
213
+
214
+
Finally, ensure that the directory containing the dynamic libraries (DLLs) is added to the `PATH` environment variable. Set this in the Windows system settings. After setting the environment variable, restart Visual Studio to apply the changes.
215
+
216
+

217
+
218
+
### Run the build
219
+
220
+
Once these steps are complete, you're ready to build. From the top menu, select `Debug` and click `Start Without Debugging` or press `Ctrl` + `F5`.
221
+
222
+
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. When you open the image file, it should look like the example shown below.
223
+
224
+

225
+
226
+
Congratulations! You are now ready to create your own OpenCV applications.
0 commit comments