Initial work in making it compatible with Epsilon

This commit is contained in:
Deukhoofd 2021-07-13 21:39:50 +02:00
parent 8bc6cfc269
commit e8daa65e6c
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
7 changed files with 199 additions and 2 deletions

123
.clang-format Normal file
View File

@ -0,0 +1,123 @@
# ClangFormatConfigureSource: 'LLVM'
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Merge
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 1
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
- Assert
- AssertNotNull
TabWidth: 8
UseTab: Never
...

11
.clang-tidy Normal file
View File

@ -0,0 +1,11 @@
Checks: 'readability-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,performance-*,cppcoreguidelines-*,
bugprone-*,modernize-*,-modernize-use-trailing-return-type'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.PrivateMemberCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberPrefix
value: '_'

View File

@ -9,6 +9,7 @@ add_compile_options(-Wall -Wextra -Werror)
option(WINDOWS "Whether the build target is Windows or not." OFF) option(WINDOWS "Whether the build target is Windows or not." OFF)
option(SHARED "Whether we should build a shared library, instead of a static one." OFF) option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
option(DEMO "Whether or not the demo should be built." OFF) option(DEMO "Whether or not the demo should be built." OFF)
option(OPENCV "Whether or not opencv should be targeted." OFF)
if (NOT WINDOWS) if (NOT WINDOWS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -44,6 +45,15 @@ if (STATICC)
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
set(LINKS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread -Wl,-Bdynamic ${LINKS}) set(LINKS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread -Wl,-Bdynamic ${LINKS})
endif(STATICC) endif(STATICC)
if (OPENCV)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_definitions(-D ATOMORPH_OPENCV)
set(LINKS ${LINKS} ${OpenCV_LIBS})
endif()
target_link_libraries(atomorph ${LINKS}) target_link_libraries(atomorph ${LINKS})
if (DEMO) if (DEMO)

View File

@ -1,6 +1,8 @@
# atomorph # atomorph
Image morphing library that uses fluid dynamics and optimal transport to produce intuitive morphs. Image morphing library that uses fluid dynamics and optimal transport to produce intuitive morphs.
Adapted for use for Epsilon.
http://atomorph.org http://atomorph.org
AtoMorph Library uses the C++11 standard. The included Makefiles AtoMorph Library uses the C++11 standard. The included Makefiles

50
src/EpsilonHook.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "morph.h"
#define export extern "C" [[maybe_unused]]
export am::morph* create_morph(uint16_t width, uint16_t height, uint8_t img_a[], uint8_t img_b[]) {
auto* morph = new am::morph();
morph->set_blob_delimiter (am::HSP);
morph->set_blob_max_size (128);
morph->set_blob_min_size (3);
morph->set_blob_box_grip (16);
morph->set_blob_box_samples(-1);
morph->set_blob_threshold (128);
morph->set_blob_number (1);
morph->set_seed (0);
morph->set_blob_rgba_weight(1);
morph->set_blob_size_weight(0);
morph->set_blob_xy_weight (0);
morph->set_degeneration (10000);
morph->set_density (2); // Higher than 1 sets fluid to 0.
morph->set_motion (am::SPLINE);
morph->set_fading (am::PERLIN);
morph->set_threads (8);
morph->set_cycle_length (100000);
morph->set_feather (0);
morph->set_keep_background (0);
morph->set_finite (1);
morph->set_show_blobs (am::TEXTURE);
morph->set_fluid (0); // Higher than 0 sets density to 1.
morph->set_resolution(width, height);
for (int i = 0; i < width * height; i++) {
auto real_index = i * 4;
morph->add_pixel(0, am::create_pixel(i % width, i / width, img_a[real_index], img_a[real_index + 1],
img_a[real_index + 2], img_a[real_index + 3]));
}
for (int i = 0; i < width * height; i++) {
auto real_index = i * 4;
morph->add_pixel(1, am::create_pixel(i % width, i / width, img_b[real_index], img_b[real_index + 1],
img_b[real_index + 2], img_b[real_index + 3]));
}
morph->compute();
return morph;
}
export void delete_morph(am::morph* morph) { delete morph; }

View File

@ -18,7 +18,7 @@
#include <cstdint> #include <cstdint>
#ifdef ATOMORPH_OPENCV #ifdef ATOMORPH_OPENCV
#include <opencv/cv.h> #include <opencv2/opencv.hpp>
#endif #endif
#include "spline.h" #include "spline.h"

View File

@ -1,6 +1,7 @@
/* /*
* See Copyright Notice in atomorph.h * See Copyright Notice in atomorph.h
*/ */
#pragma once
#include "atomorph.h" #include "atomorph.h"