Skip to content

Commit

Permalink
gtk build for linux (#277)
Browse files Browse the repository at this point in the history
* added gtk feature in opencv dependencies

* skipping gtk on arm and windows

* by mistake include gtk 2 times removed one

* just skipping arm64

* added an xdmage package to x11 to build on linux

* updated the Readme with necessary dependencies

---------

Co-authored-by: Mradul Dubey <[email protected]>
  • Loading branch information
venkat0907 and mraduldubey authored Aug 29, 2023
1 parent 080ccf8 commit 0d03309
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-lin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ on:
prep-cmd:
type: string
description: 'commands required to be run on a builder to prep it for build'
default: 'sudo apt-get update -qq && sudo apt-get -y install ca-certificates curl zip unzip tar autoconf automake autopoint build-essential flex git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libsoup-gnome2.4-dev libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libncurses5-dev libncursesw5-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison python3 python3-pip dos2unix && pip3 install meson'
default: 'sudo apt-get update -qq && sudo apt-get -y install ca-certificates curl zip unzip tar autoconf automake autopoint build-essential flex git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libsoup-gnome2.4-dev libva-dev libvdpau-dev libvorbis-dev libxdamage-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libncurses5-dev libncursesw5-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison python3 python3-pip dos2unix && pip3 install meson'
required: false
prep-check-cmd:
type: string
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Aprapipes is automatically built and tested on Ubuntu (18.04 and 20.04), Jetson
### Prerequisites
* Run the following to get latest build tools
```
sudo apt-get update && sudo apt-get -y install autoconf automake autopoint build-essential git-core git-lfs libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libssl-dev libtool libsoup-gnome2.4-dev libncurses5-dev libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison curl zip unzip tar python3-pip flex && pip3 install meson
sudo apt-get update && sudo apt-get -y install autoconf automake autopoint build-essential git-core git-lfs libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libssl-dev libtool libsoup-gnome2.4-dev libncurses5-dev libva-dev libvdpau-dev libvorbis-dev libxdamage-dev libxcursor-dev libxinerama-dev libx11-dev libgles2-mesa-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm gperf bison curl zip unzip tar python3-pip flex && pip3 install meson
```
* Note: start a new terminal as pip3 settings do not get effective on the same shell
* CMake minimum version 3.24 - Follow [this article](https://anglehit.com/how-to-install-the-latest-version-of-cmake-via-command-line/) to update cmake
Expand Down
10 changes: 5 additions & 5 deletions base/fix-vcpkg-json.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ param([String]$fileName='vcpkg.json', [switch]$removeOpenCV, [switch]$removeCUD

$v = Get-Content $fileName -raw | ConvertFrom-Json

if($removeCUDA.IsPresent)
if ($removeCUDA.IsPresent)
{
$opencv = $v.dependencies | Where-Object { $_.name -eq 'opencv4'}
$opencv.features= $opencv.features | Where-Object { $_ -ne 'cuda' }
$opencv.features= $opencv.features | Where-Object { $_ -ne 'cudnn' }
$v.dependencies |
Where-Object { $_.name -eq 'opencv4' } |
ForEach-Object { $_.features = $_.features -ne 'cuda' -ne 'cudnn' }
}

if($removeOpenCV.IsPresent)
Expand All @@ -24,4 +24,4 @@ if($onlyOpenCV.IsPresent)
}


$v | ConvertTo-Json -depth 32| set-content $fileName
$v | ConvertTo-Json -depth 32| set-content $fileName
52 changes: 32 additions & 20 deletions base/fix-vcpkg-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,47 @@ echo "$v"

# Process command line arguments
if $removeCUDA; then
echo "Removing CUDA..."
opencv=$(echo "$v" | jq '.dependencies[] | select(type == "string" or .name == "opencv4")')
opencv=$(echo "$opencv" | jq '.features |= map(select(. != "cuda" and . != "cudnn"))')
v=$(echo "$v" | jq '.dependencies[] |= select(type == "string" or .name != "opencv4")')
v=$(echo "$v" | jq '.dependencies[] |= select(type != "null")')
v=$(echo "$v" | jq ".dependencies += [$opencv]")
echo "Removing CUDA..."
# Loop through each "opencv4" instance
for index in $(echo "$v" | jq -r '.dependencies | keys | .[]'); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" == "opencv4" ]; then
# Remove "cuda" and "cudnn" features for this "opencv4" instance
v=$(echo "$v" | jq ".dependencies[$index].features |= map(select(. != \"cuda\" and . != \"cudnn\"))")
fi
done
fi

if $removeOpenCV; then
echo "Removing OpenCV..."
v=$(echo "$v" | jq '.dependencies[] |= select(type == "string" or .name != "opencv4")')
v=$(echo "$v" | jq '.dependencies[] |= select(type != "null")')
count=$(echo "$v" | jq '.dependencies | length')
for ((index=count-1; index >= 0; index--)); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" == "opencv4" ]; then
# Remove the entire "opencv4" instance
v=$(echo "$v" | jq "del(.dependencies[$index])")
fi
done
fi

if $onlyOpenCV; then
echo "Keeping only OpenCV..."
opencv=$(echo "$v" | jq '.dependencies[] | select(.name == "opencv4")')
opencv=$(echo "$opencv" | jq '.features |= map(select(. != "cuda" and . != "cudnn"))')
v=$(echo "$v" | jq '.dependencies = []')
v=$(echo "$v" | jq ".dependencies += [$opencv]")

echo "Keeping only OpenCV..."
# Loop through each dependency and remove other dependencies except "opencv4"
count=$(echo "$v" | jq '.dependencies | length')
for ((index = count - 1; index >= 0; index--)); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" != "opencv4" ]; then
# Remove the entire dependency
v=$(echo "$v" | jq "del(.dependencies[$index])")
fi
done
fi

#Save the modified object back to the JSON file
echo "Modified JSON file contents:"
echo "$v" | jq .
echo "$v" | jq . > "$fileName"
# Save the modified object back to the JSON file
echo "Modified JSON file contents:"
echo "$v" | jq .
echo "$v" | jq . > "$fileName"

# Print all command line arguments
echo "Command line arguments:"
echo "$@"

echo "$@"
23 changes: 23 additions & 0 deletions base/test/webcam_source_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "PipeLine.h"
#include "WebCamSource.h"
#include "ExternalSinkModule.h"
#include "ImageViewerModule.h"

BOOST_AUTO_TEST_SUITE(webcam_tests, * boost::unit_test::disabled())

Expand Down Expand Up @@ -64,4 +65,26 @@ BOOST_AUTO_TEST_CASE(basic_small)
BOOST_TEST(sink->term());
}

BOOST_AUTO_TEST_CASE(viewer_test)
{
WebCamSourceProps webCamSourceprops(-1, 640, 480);
auto source = boost::shared_ptr<WebCamSource>(new WebCamSource(webCamSourceprops));

auto sink = boost::shared_ptr<Module>(new ImageViewerModule(ImageViewerModuleProps("imageview")));
source->setNext(sink);

PipeLine p("test");
p.appendModule(source);
p.init();

p.run_all_threaded();
boost::this_thread::sleep_for(boost::chrono::seconds(10));

LOG_INFO << "profiling done - stopping the pipeline";
p.stop();
p.term();
p.wait_for_all();

}

BOOST_AUTO_TEST_SUITE_END()
9 changes: 9 additions & 0 deletions base/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"tiff",
"webp"
]
},
{
"name": "opencv4",
"default-features": false,
"features": [
"gtk"
],
"platform": "(linux \u0026 x64)",
"$reason": "skip linux:arm64 and windows"
},
"libjpeg-turbo",
"openh264",
Expand Down
2 changes: 1 addition & 1 deletion build_linux_no_cuda.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
chmod +x base/fix-vcpkg-json.sh
./base/fix-vcpkg-json.sh true fasle false
./base/fix-vcpkg-json.sh true false false
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
Expand Down

0 comments on commit 0d03309

Please sign in to comment.