Skip to content

Commit

Permalink
Rename project
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPushkin committed May 21, 2022
1 parent babf38f commit 88b994d
Show file tree
Hide file tree
Showing 39 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Android
on: [ push, workflow_dispatch ]

env:
NATIVE_PROJECT_SUBDIR: sgbmandroid/src/main/cpp
NATIVE_PROJECT_SUBDIR: sgbmdepth/src/main/cpp
BUILD_SUBDIR: build
ABIS: "armeabi-v7a arm64-v8a x86 x86_64"
TOOLCHAIN_SUBPATH: build/cmake/android.toolchain.cmake
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
run: chmod +x gradlew

- name: Build Android library
run: ./gradlew :sgbmandroid:build
run: ./gradlew :sgbmdepth:build

- name: Build Android app
run: ./gradlew :app:build
10 changes: 5 additions & 5 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on: [ push, workflow_dispatch ]

env:
BUILD_TYPE: Debug
PROJECT_SUBDIR: sgbmandroid/src/main/cpp
PROJECT_SUBDIR: sgbmdepth/src/main/cpp
BUILD_SUBDIR: build

defaults:
run:
shell: bash
working-directory: sgbmandroid/src/main/cpp # Must be the same as env.PROJECT_SUBDIR
working-directory: sgbmdepth/src/main/cpp # Must be the same as env.PROJECT_SUBDIR

jobs:
build:
Expand All @@ -25,7 +25,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{github.workspace}}/${{env.PROJECT_SUBDIR}}/${{env.BUILD_SUBDIR}}
key: ${{runner.os}}-build-cache-v4
key: ${{runner.os}}-build-cache

- name: Prepare OpenCV
run: cmake -P BuildOpenCV.cmake
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
path: |
~/.cmodule
${{github.workspace}}/${{env.PROJECT_SUBDIR}}/${{env.BUILD_SUBDIR}}
key: ${{runner.os}}-build-cache-bridge-v2
key: ${{runner.os}}-build-cache-bridge

- name: Prepare OpenCV
run: cmake -P BuildOpenCV.cmake
Expand All @@ -81,7 +81,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{github.workspace}}/${{env.PROJECT_SUBDIR}}/${{env.BUILD_SUBDIR}}
key: ${{runner.os}}-build-cache-v4
key: ${{runner.os}}-build-cache

- name: Configure linters
run: |
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SgbmAndroid
# SgbmDepth

Android library for depth estimation based on
[StereoSGBM](https://docs.opencv.org/4.5.5/d2/d85/classcv_1_1StereoSGBM.html) from OpenCV.
Expand All @@ -21,23 +21,23 @@ Two options are available:

1. **(Recommended)** Run `BuildOpenCV.cmake` script which will download and build OpenCV
automatically with the recommended optimizations. Read more about how to run the script in the
[native part's README](sgbmandroid/src/main/cpp/README.md). You have to run it once for every
[native part's README](sgbmdepth/src/main/cpp/README.md). You have to run it once for every
Android ABI you plan to use.
2. Download and install the prebuilt [OpenCV Android SDK](https://opencv.org/releases). It may lack
some possible optimizations.

After OpenCV is installed build the project with Gradle -- the library is available in
`:sgbmandroid` module. It builds for all ABIs.
`:sgbmdepth` module. It builds for all ABIs.

Currently, the library is automatically generated from its native implementation, so no
documentation is available in the resulting code. To read the `DepthEstimator` documentation see
[its native header](sgbmandroid/src/main/cpp/include/DepthEstimator.h).
[its native header](sgbmdepth/src/main/cpp/include/DepthEstimator.h).

## Demo application

An example application is available in `:app` module. It computes a depth map from a pair of images
using the chosen calibration parameters and displays the resulting image also showing the time it
took to compute. You can get a sample stereo pair and calibration parameters for it
[here](sgbmandroid/src/main/cpp/examples/images) to try it out and test the performance.
[here](sgbmdepth/src/main/cpp/examples/images) to try it out and test the performance.

<img src="https://i.imgur.com/Ch1MW4G.png" alt="Demo application GUI"/>
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ plugins {
android {
compileSdk 31

namespace 'me.timpushkin.sgbmandroidapp'
namespace 'me.timpushkin.sgbmdepthapp'

defaultConfig {
applicationId 'me.timpushkin.sgbmandroidapp'
applicationId 'me.timpushkin.sgbmdepthapp'
minSdk 21
targetSdk 31
versionCode 1
Expand Down Expand Up @@ -57,7 +57,7 @@ dependencies {
implementation 'com.squareup.okio:okio:3.1.0'
implementation 'com.google.modernstorage:modernstorage-storage:1.0.0-alpha06'

implementation project(':sgbmandroid')
implementation project(':sgbmdepth')
}

ktlint {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SgbmAndroid">
android:theme="@style/Theme.SgbmDepthApp">
<activity
android:name="me.timpushkin.sgbmandroidapp.MainActivity"
android:name="me.timpushkin.sgbmdepthapp.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.timpushkin.sgbmandroidapp
package me.timpushkin.sgbmdepthapp

import android.graphics.Bitmap
import android.net.Uri
Expand All @@ -15,12 +15,12 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import kotlinx.coroutines.launch
import me.timpushkin.sgbmandroid.DepthEstimator
import me.timpushkin.sgbmandroidapp.ui.AppState
import me.timpushkin.sgbmandroidapp.ui.Menu
import me.timpushkin.sgbmandroidapp.ui.ResultsScreen
import me.timpushkin.sgbmandroidapp.utils.StorageUtils
import me.timpushkin.sgbmandroidapp.utils.depthArrayToBitmap
import me.timpushkin.sgbmdepth.DepthEstimator
import me.timpushkin.sgbmdepthapp.ui.AppState
import me.timpushkin.sgbmdepthapp.ui.Menu
import me.timpushkin.sgbmdepthapp.ui.ResultsScreen
import me.timpushkin.sgbmdepthapp.utils.StorageUtils
import me.timpushkin.sgbmdepthapp.utils.depthArrayToBitmap

private const val CACHED_PARAMS = "params.xml"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package me.timpushkin.sgbmandroidapp.ui
package me.timpushkin.sgbmdepthapp.ui

import android.graphics.Bitmap
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import me.timpushkin.sgbmandroid.DepthEstimator
import me.timpushkin.sgbmdepth.DepthEstimator

class AppState : ViewModel() {
var depthEstimator by mutableStateOf<DepthEstimator?>(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.timpushkin.sgbmandroidapp.ui
package me.timpushkin.sgbmdepthapp.ui

import android.net.Uri
import android.webkit.MimeTypeMap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.timpushkin.sgbmandroidapp.ui
package me.timpushkin.sgbmdepthapp.ui

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.timpushkin.sgbmandroidapp.utils
package me.timpushkin.sgbmdepthapp.utils

import android.graphics.Bitmap
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.timpushkin.sgbmandroidapp.utils
package me.timpushkin.sgbmdepthapp.utils

import android.content.Context
import android.net.Uri
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">SgbmAndroid</string>
<string name="app_name">SgbmDepth</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.SgbmAndroid" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.SgbmDepthApp" parent="android:Theme.Material.Light.NoActionBar" />
</resources>
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ dependencyResolutionManagement {
}
}

rootProject.name = "SgbmAndroid"
include ':app', ':sgbmandroid'
rootProject.name = "SgbmDepth"
include ':app', ':sgbmdepth'
File renamed without changes.
2 changes: 1 addition & 1 deletion sgbmandroid/build.gradle → sgbmdepth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
compileSdk 31
ndkVersion '23.1.7779620'

namespace 'me.timpushkin.sgbmandroid'
namespace 'me.timpushkin.sgbmdepth'

defaultConfig {
minSdk 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
}

# ProGuard might remove DepthEstimator otherwise
-keep class me.timpushkin.sgbmandroid.DepthEstimator { *; }
-keep class me.timpushkin.sgbmdepth.DepthEstimator { *; }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(sgbmandroid)
project(sgbmdepth)

option(BUILD_EXAMPLES "Build examples" OFF)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Native core of SgbmAndroid library
# Native core of SgbmDepth library

This directory contains the native implementation of the SGBM-based depth estimation algorithm.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) {
auto lImg = streamToVector(lImgStream);
auto rImg = streamToVector(rImgStream);

sgbmandroid::DepthEstimator depthEstimator(calibPath);
sgbmdepth::DepthEstimator depthEstimator(calibPath);
auto depth = depthEstimator.estimateDepth(lImg, rImg);

for (const auto &row : depth) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SGBMANDROID_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_
#define SGBMANDROID_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_
#ifndef SGBMDEPTH_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_
#define SGBMDEPTH_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_

#include <string>
#include <vector>
Expand All @@ -12,7 +12,7 @@

#include <scapix/bridge/object.h>

namespace sgbmandroid {
namespace sgbmdepth {

namespace internal {

Expand All @@ -21,11 +21,11 @@ using base_object = scapix::bridge::object<T>;

} // namespace internal

} // namespace sgbmandroid
} // namespace sgbmdepth

#else

namespace sgbmandroid {
namespace sgbmdepth {

namespace internal {

Expand All @@ -35,11 +35,11 @@ class base_object {

} // namespace internal

} // namespace sgbmandroid
} // namespace sgbmdepth

#endif // SCAPIX_BRIDGE

namespace sgbmandroid {
namespace sgbmdepth {

// Computes a depth map from a pair of images.
class DepthEstimator : public internal::base_object<DepthEstimator> {
Expand Down Expand Up @@ -136,6 +136,6 @@ class DepthEstimator : public internal::base_object<DepthEstimator> {
void getDepthFromDisparity(cv::InputArray disparity, cv::OutputArray dst) const;
};

} // namespace sgbmandroid
} // namespace sgbmdepth

#endif // SGBMANDROID_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_
#endif // SGBMDEPTH_SRC_MAIN_CPP_INCLUDE_DEPTHESTIMATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (DEFINED SCAPIX_BRIDGE)

find_package(Scapix REQUIRED)

scapix_bridge_headers(${PROJECT_NAME} me.timpushkin.sgbmandroid ${HEADER_FILES})
scapix_bridge_headers(${PROJECT_NAME} me.timpushkin.sgbmdepth ${HEADER_FILES})

message(STATUS "Configuring Scapix - done")
endif ()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SGBMANDROID_SRC_MAIN_CPP_SRC_CONSTANTS_H_
#define SGBMANDROID_SRC_MAIN_CPP_SRC_CONSTANTS_H_
#ifndef SGBMDEPTH_SRC_MAIN_CPP_SRC_CONSTANTS_H_
#define SGBMDEPTH_SRC_MAIN_CPP_SRC_CONSTANTS_H_

namespace sgbmandroid {
namespace sgbmdepth {

namespace internal {

Expand All @@ -28,6 +28,6 @@ constexpr auto scaleDependentQColIndex = 3;

} // namespace internal

} // namespace sgbmandroid
} // namespace sgbmdepth

#endif // SGBMANDROID_SRC_MAIN_CPP_SRC_CONSTANTS_H_
#endif // SGBMDEPTH_SRC_MAIN_CPP_SRC_CONSTANTS_H_
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SGBMANDROID_SRC_MAIN_CPP_SRC_CONVERSIONS_H_
#define SGBMANDROID_SRC_MAIN_CPP_SRC_CONVERSIONS_H_
#ifndef SGBMDEPTH_SRC_MAIN_CPP_SRC_CONVERSIONS_H_
#define SGBMDEPTH_SRC_MAIN_CPP_SRC_CONVERSIONS_H_

#include <vector>
#include "opencv2/core.hpp"
Expand Down Expand Up @@ -29,4 +29,4 @@ std::vector<std::vector<T>> twoDimMatToTwoDimVector(const cv::Mat &mat) {
return result;
}

#endif // SGBMANDROID_SRC_MAIN_CPP_SRC_CONVERSIONS_H_
#endif // SGBMDEPTH_SRC_MAIN_CPP_SRC_CONVERSIONS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Conversions.h"
#include "Logging.h"

namespace sgbmandroid {
namespace sgbmdepth {

constexpr auto kTag = "DepthEstimator";

Expand Down Expand Up @@ -138,4 +138,4 @@ void DepthEstimator::setImageScaleFactor(float value) {
sgbm->setNumDisparities(static_cast<int> (mUnscaledMaxDisparity * value) - internal::minDisparity);
}

} // namespace sgbmandroid
} // namespace sgbmdepth
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SGBMANDROID_SRC_MAIN_CPP_SRC_LOGGING_H_
#define SGBMANDROID_SRC_MAIN_CPP_SRC_LOGGING_H_
#ifndef SGBMDEPTH_SRC_MAIN_CPP_SRC_LOGGING_H_
#define SGBMDEPTH_SRC_MAIN_CPP_SRC_LOGGING_H_

#ifndef NDEBUG

Expand Down Expand Up @@ -104,4 +104,4 @@ void logE(const char *tag, const char *format...) {}

#endif // NDEBUG

#endif // SGBMANDROID_SRC_MAIN_CPP_SRC_LOGGING_H_
#endif // SGBMDEPTH_SRC_MAIN_CPP_SRC_LOGGING_H_

0 comments on commit 88b994d

Please sign in to comment.