Skip to content

Commit

Permalink
Methods updated, examples added
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstantRobotics committed Sep 24, 2023
1 parent 7fe6a21 commit 4e134b3
Show file tree
Hide file tree
Showing 16 changed files with 728 additions and 145 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endif()
################################################################################
SET(${PARENT}_VSTABILISER ON CACHE BOOL "" ${REWRITE_FORCE})
SET(${PARENT}_VSTABILISER_TEST ON CACHE BOOL "" ${REWRITE_FORCE})
SET(${PARENT}_VSTABILISER_EXAMPLE ON CACHE BOOL "" ${REWRITE_FORCE})



Expand All @@ -46,3 +47,7 @@ endif()
if (${PARENT}_VSTABILISER_TEST)
add_subdirectory(test)
endif()

if (${PARENT}_VSTABILISER_EXAMPLE)
add_subdirectory(example)
endif()
323 changes: 191 additions & 132 deletions README.md

Large diffs are not rendered by default.

Binary file removed VStabiliser interface C++ class.pdf
Binary file not shown.
Binary file added VStabiliser_interface_C++_library_v2.2.0.pdf
Binary file not shown.
Binary file removed _static/vstabiliser_logo.png
Binary file not shown.
Binary file added _static/vstabiliser_web_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.13)



################################################################################
## LIBRARY-PROJECT
## name and version
################################################################################
project(CustomVStabiliser VERSION 1.0.0 LANGUAGES CXX)



################################################################################
## SETTINGS
## basic project settings before use
################################################################################
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Enabling export of all symbols to create a dynamic library
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# creating output directory architecture in accordance with GNU guidelines
set(BINARY_DIR "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BINARY_DIR}/lib")
file (GLOB_RECURSE IN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h.in)
configure_file(${IN_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Version.h)



################################################################################
## TARGET
## create target and add include path
################################################################################
# create glob files for *.h, *.cpp
file (GLOB_RECURSE H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file (GLOB_RECURSE CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# concatenate the results (glob files) to variable
set (SOURCES ${CPP_FILES} ${H_FILES})
# create lib from src
if (NOT TARGET ${PROJECT_NAME})
add_library(${PROJECT_NAME} STATIC ${SOURCES})
endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})



################################################################################
## LINK LIBRARIES
## linking all dependencies
################################################################################
target_link_libraries(${PROJECT_NAME} VStabiliser)

328 changes: 328 additions & 0 deletions example/CustomVStabiliser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
#include "CustomVStabiliser.h"
#include "CustomVStabiliserVersion.h"



cr::vstab::CustomVStabiliser::CustomVStabiliser()
{

}



cr::vstab::CustomVStabiliser::~CustomVStabiliser()
{

}



std::string cr::vstab::CustomVStabiliser::getVersion()
{
return CUSTOM_VSTABILISER_VERSION;
}



bool cr::vstab::CustomVStabiliser::initVStabiliser(cr::vstab::VStabiliserParams& params)
{
// Copy params.
m_params = params;

return true;
}



bool cr::vstab::CustomVStabiliser::setParam(cr::vstab::VStabiliserParam id, float value)
{
// Check parameter ID.
switch (id)
{
case cr::vstab::VStabiliserParam::SCALE_FACTOR:
{
m_params.scaleFactor = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::X_OFFSET_LIMIT:
{
m_params.xOffsetLimit = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::Y_OFFSET_LIMIT:
{
m_params.yOffsetLimit = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::A_OFFSET_LIMIT:
{
m_params.aOffsetLimit = value;
return true;
}
case cr::vstab::VStabiliserParam::X_FILTER_COEFF:
{
m_params.xFilterCoeff = value;
return true;
}
case cr::vstab::VStabiliserParam::Y_FILTER_COEFF:
{
m_params.yFilterCoeff = value;
return true;
}
case cr::vstab::VStabiliserParam::A_FILTER_COEFF:
{
m_params.aFilterCoeff = value;
return true;
}
case cr::vstab::VStabiliserParam::MODE:
{
m_params.enable = (int)value == 0 ? false : true;
return true;
}
case cr::vstab::VStabiliserParam::TRANSPARENT_BORDER:
{
m_params.transparentBorder = (int)value == 0 ? false : true;
return true;
}
case cr::vstab::VStabiliserParam::CONST_X_OFFSET:
{
m_params.constXOffset = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::CONST_Y_OFFSET:
{
m_params.constYOffset = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::CONST_A_OFFSET:
{
m_params.constAOffset = value;
return true;
}
case cr::vstab::VStabiliserParam::INSTANT_X_OFFSET:
{
m_params.instantXOffset = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::INSTANT_Y_OFFSET:
{
m_params.instantYOffset = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::INSTANT_A_OFFSET:
{
m_params.instantAOffset = value;
return true;
}
case cr::vstab::VStabiliserParam::TYPE:
{
m_params.type = (int)value;
return true;
}
case cr::vstab::VStabiliserParam::CUT_FREQUENCY_HZ:
{
m_params.cutFrequencyHz = value;
return true;
}
case cr::vstab::VStabiliserParam::FPS:
{
m_params.fps = value;
return true;
}
case cr::vstab::VStabiliserParam::PROCESSING_TIME_MKS:
{
// Read only parameter.
return false;
}
case cr::vstab::VStabiliserParam::LOG_MODE:
{
m_params.logMod = (int)value;
return true;
}
default:
{
return false;
}
}

return false;
}



float cr::vstab::CustomVStabiliser::getParam(VStabiliserParam id)
{
// Check parameter ID.
switch (id)
{
case cr::vstab::VStabiliserParam::SCALE_FACTOR:
{
return (float)m_params.scaleFactor;
}
case cr::vstab::VStabiliserParam::X_OFFSET_LIMIT:
{
return (float)m_params.xOffsetLimit;
}
case cr::vstab::VStabiliserParam::Y_OFFSET_LIMIT:
{
return (float)m_params.yOffsetLimit;
}
case cr::vstab::VStabiliserParam::A_OFFSET_LIMIT:
{
return m_params.aOffsetLimit;
}
case cr::vstab::VStabiliserParam::X_FILTER_COEFF:
{
return m_params.xFilterCoeff;
}
case cr::vstab::VStabiliserParam::Y_FILTER_COEFF:
{
return m_params.yFilterCoeff;
}
case cr::vstab::VStabiliserParam::A_FILTER_COEFF:
{
return m_params.aFilterCoeff;
}
case cr::vstab::VStabiliserParam::MODE:
{
return m_params.enable ? 1.0f : 0.0f;
}
case cr::vstab::VStabiliserParam::TRANSPARENT_BORDER:
{
return m_params.transparentBorder ? 1.0f : 0.0f;
}
case cr::vstab::VStabiliserParam::CONST_X_OFFSET:
{
return (float)m_params.constXOffset;
}
case cr::vstab::VStabiliserParam::CONST_Y_OFFSET:
{
return (float)m_params.constYOffset;
}
case cr::vstab::VStabiliserParam::CONST_A_OFFSET:
{
return m_params.constAOffset;
}
case cr::vstab::VStabiliserParam::INSTANT_X_OFFSET:
{
return (float)m_params.instantXOffset;
}
case cr::vstab::VStabiliserParam::INSTANT_Y_OFFSET:
{
return (float)m_params.instantYOffset;
}
case cr::vstab::VStabiliserParam::INSTANT_A_OFFSET:
{
return m_params.instantAOffset;
}
case cr::vstab::VStabiliserParam::TYPE:
{
return (float)m_params.type;
}
case cr::vstab::VStabiliserParam::CUT_FREQUENCY_HZ:
{
return m_params.cutFrequencyHz;
}
case cr::vstab::VStabiliserParam::FPS:
{
return m_params.fps;
}
case cr::vstab::VStabiliserParam::PROCESSING_TIME_MKS:
{
return (float)m_params.processingTimeMks;
}
case cr::vstab::VStabiliserParam::LOG_MODE:
{
return (float)m_params.logMod;
}
default:
{
return -1.0f;
}
}

return -1.0f;
}



cr::vstab::VStabiliserParams cr::vstab::CustomVStabiliser::getParams()
{
return m_params;
}



bool cr::vstab::CustomVStabiliser::executeCommand(VStabiliserCommand id)
{
// Check command ID.
switch (id)
{
case cr::vstab::VStabiliserCommand::RESET:
{
return true;
}
case cr::vstab::VStabiliserCommand::ON:
{
return true;
}
case cr::vstab::VStabiliserCommand::OFF:
{
return true;
}
default:
{
return false;
}
}

return false;
}



bool cr::vstab::CustomVStabiliser::stabilise(cr::video::Frame& src, cr::video::Frame& dst)
{
// Copy frame.
dst = src;

return true;
}



void cr::vstab::CustomVStabiliser::getOffsets(float& dX, float& dY, float& dA)
{
dX = (float)m_params.instantXOffset;
dY = (float)m_params.instantYOffset;
dA = m_params.instantAOffset;
}



bool cr::vstab::CustomVStabiliser::decodeAndExecuteCommand(uint8_t* data, int size)
{
// Init params.
VStabiliserParam paramId;
VStabiliserCommand commandId;
float value = 0.0f;

// Decode.
switch (VStabiliser::decodeCommand(data, size, paramId, commandId, value))
{
case 0:
{
return executeCommand(commandId);
}
case 1:
{
return setParam(paramId, value);
}
default:
{
return false;
}
}

return true;
}
Loading

0 comments on commit 4e134b3

Please sign in to comment.