-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from JuliaRobotics/23Q3/enh/readme
readme and ImagesExt
- Loading branch information
Showing
10 changed files
with
546 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,25 @@ jobs: | |
julia-version: ['1.9', '~1.10.0-0', 'nightly'] | ||
os: [ubuntu-latest] | ||
arch: [x64] | ||
# https://github.com/ros-tooling/action-ros-ci/blob/master/.github/workflows/test.yml | ||
ros_distribution: | ||
- noetic | ||
include: | ||
# Noetic Ninjemys (May 2020 - May 2025) | ||
- docker_image: rostooling/setup-ros-docker:ubuntu-focal-ros-noetic-ros-base-latest | ||
ros_distribution: noetic | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: '3.9' | ||
# cache: 'pip' | ||
# - run: pip install opencv-python | ||
# - uses: ros-tooling/[email protected] | ||
# with: | ||
# required-ros-distributions: noetic | ||
# - run: "source /opt/ros/noetic/setup.bash" | ||
# docker pull osrf/ros:noetic-desktop | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.julia-version }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# PyCaesar.jl | ||
|
||
| Stable | Dev | Coverage | Docs | | ||
|--------|-----|----------|------| | ||
| [![version][pycjl-ver-img]][pycjl-releases] | [![CI][pycjl-ci-dev-img]][pycjl-ci-dev-url] | [![codecov.io][pycjl-cov-img]][pycjl-cov-url] | [![docs][cjl-docs-img]][cjl-docs-url] <br> [![][caesar-slack-badge]][caesar-slack] | | ||
|
||
## Dependencies | ||
|
||
The following packages should be available in the Python environment used by PyCall.jl | ||
|
||
``` | ||
rospy | ||
opencv-python # i.e. cv2 | ||
open3d | ||
Rosbags | ||
``` | ||
|
||
> 23Q3: We had issues in using Conda.jl to install these dependecies in a new environment, specifically conda package compliance with newer versions of Python. E.g. open3d was not available via conda on Python 3.10 at the time of writing. Please open an issue if further clarification is needed. | ||
## Introduction | ||
|
||
Caesar.jl extensions using Python. See common [Caesar.jl][cjl-docs-url] Docs for details. | ||
|
||
|
||
[pycjl-url]: http://www.github.com/JuliaRobotics/PyCaesar.jl | ||
[pycjl-cov-img]: https://codecov.io/github/JuliaRobotics/PyCaesar.jl/coverage.svg?branch=develop | ||
[pycjl-cov-url]: https://codecov.io/github/JuliaRobotics/PyCaesar.jl?branch=develop | ||
[pycjl-ci-dev-img]: https://github.com/JuliaRobotics/PyCaesar.jl/actions/workflows/CI.yml/badge.svg | ||
[pycjl-ci-dev-url]: https://github.com/JuliaRobotics/PyCaesar.jl/actions/workflows/CI.yml | ||
[pycjl-ver-img]: https://juliahub.com/docs/PyCaesar/version.svg | ||
[pycjl-milestones]: https://github.com/JuliaRobotics/PyCaesar.jl/milestones | ||
[pycjl-releases]: https://github.com/JuliaRobotics/PyCaesar.jl/releases | ||
|
||
[cjl-url]: https://github.com/JuliaRobotics/Caesar.jl | ||
[cjl-docs-img]: https://img.shields.io/badge/docs-latest-blue.svg | ||
[cjl-docs-url]: http://juliarobotics.github.io/Caesar.jl/latest/ | ||
[caesar-slack-badge]: https://img.shields.io/badge/Caesarjl-Slack-green.svg?style=popout | ||
[caesar-slack]: https://join.slack.com/t/caesarjl/shared_invite/zt-ucs06bwg-y2tEbddwX1vR18MASnOLsw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module PyCaesarImagesExt | ||
|
||
using PyCall | ||
using Images | ||
# using PyCaesars | ||
# using ImageFeatures | ||
using DistributedFactorGraphs | ||
using ProgressMeter | ||
using JSON3 | ||
using TensorCast | ||
using SHA: sha256 | ||
|
||
import PyCaesar: calcFlow, getPose, goodFeaturesToTrack, goodFeaturesToTrackORB, combinePlot | ||
import PyCaesar: trackFeaturesFrames, trackFeaturesForwardsBackwards, makeBlobFeatureTracksPerImage_FwdBck!, makeORBParams, plotBlobsImageTracks! | ||
import PyCaesar: whatcv | ||
|
||
export calcFlow, getPose, goodFeaturesToTrack, goodFeaturesToTrackORB, combinePlot | ||
export trackFeaturesFrames, trackFeaturesForwardsBackwards, makeBlobFeatureTracksPerImage_FwdBck!, makeORBParams, plotBlobsImageTracks! | ||
|
||
|
||
const np = PyNULL() | ||
const cv = PyNULL() | ||
|
||
function __init__() | ||
copy!(np, pyimport("numpy")) | ||
copy!(cv, pyimport("cv2")) | ||
end | ||
|
||
pyutilpath = joinpath(@__DIR__, "Utils") | ||
pushfirst!(PyVector(pyimport("sys")."path"), pyutilpath ) | ||
|
||
SscPy = pyimport("PySSCFeatures") | ||
ssc = SscPy."ssc" | ||
|
||
|
||
include("services/OpenCVFeatures.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Taken from: https://github.com/BAILOOL/ANMS-Codes/blob/568fa6a1b39aa46fa04ad600cb40a33decf52897/Python/ssc.py#L1 | ||
|
||
# @article{bailo2018efficient, | ||
# title={Efficient adaptive non-maximal suppression algorithms for homogeneous spatial keypoint distribution}, | ||
# author={Bailo, Oleksandr and Rameau, Francois and Joo, Kyungdon and Park, Jinsun and Bogdan, Oleksandr and Kweon, In So}, | ||
# journal={Pattern Recognition Letters}, | ||
# volume={106}, | ||
# pages={53--60}, | ||
# year={2018}, | ||
# publisher={Elsevier} | ||
# } | ||
|
||
# MIT "Expat" License | ||
|
||
# Copyright (c) 2018 Oleksandr Bailo | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import math | ||
|
||
def ssc(keypoints, num_ret_points, tolerance, cols, rows): | ||
exp1 = rows + cols + 2 * num_ret_points | ||
exp2 = ( | ||
4 * cols | ||
+ 4 * num_ret_points | ||
+ 4 * rows * num_ret_points | ||
+ rows * rows | ||
+ cols * cols | ||
- 2 * rows * cols | ||
+ 4 * rows * cols * num_ret_points | ||
) | ||
exp3 = math.sqrt(exp2) | ||
exp4 = num_ret_points - 1 | ||
|
||
sol1 = -round(float(exp1 + exp3) / exp4) # first solution | ||
sol2 = -round(float(exp1 - exp3) / exp4) # second solution | ||
|
||
high = ( | ||
sol1 if (sol1 > sol2) else sol2 | ||
) # binary search range initialization with positive solution | ||
low = math.floor(math.sqrt(len(keypoints) / num_ret_points)) | ||
|
||
prev_width = -1 | ||
selected_keypoints = [] | ||
result_list = [] | ||
result = [] | ||
complete = False | ||
k = num_ret_points | ||
k_min = round(k - (k * tolerance)) | ||
k_max = round(k + (k * tolerance)) | ||
|
||
while not complete: | ||
width = low + (high - low) / 2 | ||
if ( | ||
width == prev_width or low > high | ||
): # needed to reassure the same radius is not repeated again | ||
result_list = result # return the keypoints from the previous iteration | ||
break | ||
|
||
c = width / 2 # initializing Grid | ||
num_cell_cols = int(math.floor(cols / c)) | ||
num_cell_rows = int(math.floor(rows / c)) | ||
covered_vec = [ | ||
[False for _ in range(num_cell_cols + 1)] for _ in range(num_cell_rows + 1) | ||
] | ||
result = [] | ||
|
||
for i in range(len(keypoints)): | ||
row = int( | ||
math.floor(keypoints[i].pt[1] / c) | ||
) # get position of the cell current point is located at | ||
col = int(math.floor(keypoints[i].pt[0] / c)) | ||
if not covered_vec[row][col]: # if the cell is not covered | ||
result.append(i) | ||
# get range which current radius is covering | ||
row_min = int( | ||
(row - math.floor(width / c)) | ||
if ((row - math.floor(width / c)) >= 0) | ||
else 0 | ||
) | ||
row_max = int( | ||
(row + math.floor(width / c)) | ||
if ((row + math.floor(width / c)) <= num_cell_rows) | ||
else num_cell_rows | ||
) | ||
col_min = int( | ||
(col - math.floor(width / c)) | ||
if ((col - math.floor(width / c)) >= 0) | ||
else 0 | ||
) | ||
col_max = int( | ||
(col + math.floor(width / c)) | ||
if ((col + math.floor(width / c)) <= num_cell_cols) | ||
else num_cell_cols | ||
) | ||
for row_to_cover in range(row_min, row_max + 1): | ||
for col_to_cover in range(col_min, col_max + 1): | ||
if not covered_vec[row_to_cover][col_to_cover]: | ||
# cover cells within the square bounding box with width w | ||
covered_vec[row_to_cover][col_to_cover] = True | ||
|
||
if k_min <= len(result) <= k_max: # solution found | ||
result_list = result | ||
complete = True | ||
elif len(result) < k_min: | ||
high = width - 1 # update binary search range | ||
else: | ||
low = width + 1 | ||
prev_width = width | ||
|
||
for i in range(len(result_list)): | ||
selected_keypoints.append(keypoints[result_list[i]]) | ||
|
||
return selected_keypoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.