Skip to content

Commit

Permalink
Updated python demo script. Added virtualenv scripts for easy build a…
Browse files Browse the repository at this point in the history
…nd test the pybgs package.
  • Loading branch information
andrewssobral committed Mar 4, 2023
1 parent ad67001 commit 615c7d7
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ bgslibrary_gui
upload.sh
*.code-workspace
env
bgslibrary_env
bgslibrary_test_env
26 changes: 13 additions & 13 deletions demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ def check_opencv_version(major):
algorithms.append(bgs.TwoPoints())
algorithms.append(bgs.ViBe())
algorithms.append(bgs.CodeBook())
algorithms.append(bgs.FuzzySugenoIntegral())
algorithms.append(bgs.FuzzyChoquetIntegral())
algorithms.append(bgs.LBSimpleGaussian())
algorithms.append(bgs.LBFuzzyGaussian())
algorithms.append(bgs.LBMixtureOfGaussians())
algorithms.append(bgs.LBAdaptiveSOM())
algorithms.append(bgs.LBFuzzyAdaptiveSOM())
algorithms.append(bgs.VuMeter())
algorithms.append(bgs.KDE())
algorithms.append(bgs.IndependentMultimodal())

if is_cv2():
algorithms.append(bgs.MixtureOfGaussianV1()) # if opencv 2.x
algorithms.append(bgs.GMG()) # if opencv 2.x

if is_cv3():
algorithms.append(bgs.KNN()) # if opencv 3.x
if not is_cv2():
algorithms.append(bgs.KNN()) # if opencv > 2

if is_cv2() or is_cv3():
algorithms.append(bgs.DPAdaptiveMedian())
Expand All @@ -66,16 +76,6 @@ def check_opencv_version(major):
algorithms.append(bgs.T2FGMM_UV())
algorithms.append(bgs.T2FMRF_UM())
algorithms.append(bgs.T2FMRF_UV())
algorithms.append(bgs.FuzzySugenoIntegral())
algorithms.append(bgs.FuzzyChoquetIntegral())
algorithms.append(bgs.LBSimpleGaussian())
algorithms.append(bgs.LBFuzzyGaussian())
algorithms.append(bgs.LBMixtureOfGaussians())
algorithms.append(bgs.LBAdaptiveSOM())
algorithms.append(bgs.LBFuzzyAdaptiveSOM())
algorithms.append(bgs.VuMeter())
algorithms.append(bgs.KDE())
algorithms.append(bgs.IndependentMultimodal())
algorithms.append(bgs.MultiCue())

if is_cv2() or is_lower_or_equals_cv347():
Expand All @@ -93,7 +93,7 @@ def check_opencv_version(major):

video_file = "dataset/video.avi"


print("Number of available algorithms: ", len(algorithms))
for algorithm in algorithms:
print("Running ", algorithm.__class__)

Expand Down
46 changes: 46 additions & 0 deletions virtualenv-build-test-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Remove the existing virtual environment if it exists
rm -rf bgslibrary_env

# Create a new virtual environment called bgslibrary_env using Python3
python3 -m venv bgslibrary_env

# Activate the newly created virtual environment
source bgslibrary_env/bin/activate

# Upgrade pip and install required packages numpy and OpenCV
python -m pip install --upgrade pip
python -m pip install wheel
python -m pip install numpy
python -m pip install opencv-python

# Build and install the package using the setup.py script
python setup.py build
python setup.py install

# Set the PYTHONPATH environment variable to the build directory to access the installed library
# The following line is for Linux
export PYTHONPATH=$PYTHONPATH:$PWD/build/lib.linux-x86_64-cpython-38
# The following line is for Mac
export PYTHONPATH=$PYTHONPATH:$PWD/build/lib.macosx-11-x86_64-cpython-39

# Run demo.py and demo2.py to verify the package installation
python demo.py
python demo2.py

# Install the Twine package for uploading the distribution packages
python -m pip install twine

# Remove any existing build directory
rm -rf build/*

# Build a Wheel distribution package for the project
python setup.py bdist_wheel

# Upload any generated Wheel distribution packages using Twine
twine upload dist/*.whl

# Create a source distribution package for the project
python setup.py sdist

# Upload the generated source distribution package using Twine
twine upload dist/pybgs-*.tar.gz
30 changes: 30 additions & 0 deletions virtualenv-install-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Remove the existing virtual environment if it exists
rm -rf bgslibrary_test_env

# Create a new virtual environment called bgslibrary_test_env using Python3
python3 -m venv bgslibrary_test_env

# Activate the newly created virtual environment
source bgslibrary_test_env/bin/activate

# Upgrade pip and install required packages numpy and OpenCV
python -m pip install --upgrade pip
python -m pip install numpy
python -m pip install opencv-python

# Build and install the package using the setup.py script
# python setup.py build
# python setup.py install

# Set the PYTHONPATH environment variable to the build directory to access the installed library
# The following line is for Linux
# export PYTHONPATH=$PYTHONPATH:$PWD/build/lib.linux-x86_64-cpython-38
# The following line is for Mac
# export PYTHONPATH=$PYTHONPATH:$PWD/build/lib.macosx-11-x86_64-cpython-39

# Install the pybgs directly from PyPI
python -m pip install pybgs

# Run demo.py and demo2.py to verify the package installation
python demo.py
python demo2.py

0 comments on commit 615c7d7

Please sign in to comment.