(Left: Binary mask; Mid: Original video; Right: Bitwise add result)
To begin with, you need to install OpenCV and NumPy libraries to leverage powerful built-in functions such as cv2.VideoCapture
(for video loading) and cv2.inRange()
(for mask creation).
Using conda
as a package management tool is strongly recommended for installing OpenCV. Conda simplifies package management, dependency handling, and environment management, ensuring streamlined workflows and reproducibility.
Please download the appropriate installer for your platform (Windows/Linux/macOS) from the official Miniconda documentation page and proceed with the installation based on the detailed instructions therein.
Open a terminal and run:
conda create --name cv_env python=3.11
This will create a new Conda environment, namely cv_env
, with python=3.11
installed.
To view all the Conda environments on your PC, run:
(base) wgu@localhost ~ % conda env list
# conda environments:
#
base * /Users/wgu/miniconda3
cv_env /Users/wgu/miniconda3/envs/cv_env
Here, cv_env
is the new Conda environment that you created a few seconds ago. You can activate this Conda environment by running:
(base) wgu@localhost ~ % conda activate cv_env
(cv_env) wgu@localhost ~ %
The (cv_env)
prefix indicates the current environment you are using.
Note: You can create multiple Conda environments, each equipped with different versions of Python or other packages, to facilitate conflict-free development for distinct projects.
conda install -c conda-forge opencv
You can verify the installation by running the following commands in the terminal, which check the OpenCV version:
(cv_env) wgu@localhost ~ % python
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:49:36) [Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
4.9.0
conda install numpy
Under this repo, there are three files:
README.md
: an instruction fileno_fly_zone_detection.py
: a Python script for no-fly zone detectionno_fly_zone.mp4
: a video for emulating the top-down view from a drone flying over an urban area in our final challenge contestdef red_hsv(hsv_img):
function in no_fly_zone_detection.py
to create a mask for thresholding the red color in HSV color space此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。