summaryrefslogtreecommitdiffstats
path: root/jni/feature_mos
diff options
context:
space:
mode:
authorWei-Ta Chen <weita@google.com>2011-06-14 16:53:04 -0700
committerWei-Ta Chen <weita@google.com>2011-07-04 17:39:34 +0800
commite295e32b68cf04f0d99138bf4a6d25555f3aef99 (patch)
tree5bf19e321f357789344c0890f67f7dfa68aa8682 /jni/feature_mos
parent95fd7f77171155a087b685ca405ac3891332f638 (diff)
downloadLegacyCamera-e295e32b68cf04f0d99138bf4a6d25555f3aef99.zip
LegacyCamera-e295e32b68cf04f0d99138bf4a6d25555f3aef99.tar.gz
LegacyCamera-e295e32b68cf04f0d99138bf4a6d25555f3aef99.tar.bz2
Check in mosaic stitching codes - the native part
Updated to v4-3-2. Bug: 4990566 Change-Id: I779dcc930323353964572918510f1492828c4db4
Diffstat (limited to 'jni/feature_mos')
-rw-r--r--jni/feature_mos/doc/Readme.txt3
-rwxr-xr-xjni/feature_mos/doc/feature_mos_API_doxyfile1557
-rw-r--r--jni/feature_mos/src/mosaic/AlignFeatures.cpp148
-rw-r--r--jni/feature_mos/src/mosaic/AlignFeatures.h85
-rw-r--r--jni/feature_mos/src/mosaic/Blend.cpp1000
-rw-r--r--jni/feature_mos/src/mosaic/Blend.h113
-rw-r--r--jni/feature_mos/src/mosaic/CSite.h63
-rw-r--r--jni/feature_mos/src/mosaic/Delaunay.cpp633
-rw-r--r--jni/feature_mos/src/mosaic/Delaunay.h126
-rw-r--r--jni/feature_mos/src/mosaic/EdgePointerUtil.h37
-rw-r--r--jni/feature_mos/src/mosaic/Geometry.h156
-rw-r--r--jni/feature_mos/src/mosaic/ImageUtils.cpp363
-rw-r--r--jni/feature_mos/src/mosaic/ImageUtils.h171
-rw-r--r--jni/feature_mos/src/mosaic/Interp.h80
-rw-r--r--jni/feature_mos/src/mosaic/MatrixUtils.h141
-rw-r--r--jni/feature_mos/src/mosaic/Mosaic.cpp207
-rw-r--r--jni/feature_mos/src/mosaic/Mosaic.h201
-rw-r--r--jni/feature_mos/src/mosaic/MosaicTypes.h153
-rw-r--r--jni/feature_mos/src/mosaic/Pyramid.cpp264
-rw-r--r--jni/feature_mos/src/mosaic/Pyramid.h54
-rw-r--r--jni/feature_mos/src/mosaic/trsMatrix.cpp94
-rw-r--r--jni/feature_mos/src/mosaic/trsMatrix.h53
22 files changed, 5702 insertions, 0 deletions
diff --git a/jni/feature_mos/doc/Readme.txt b/jni/feature_mos/doc/Readme.txt
new file mode 100644
index 0000000..83ce165
--- /dev/null
+++ b/jni/feature_mos/doc/Readme.txt
@@ -0,0 +1,3 @@
+To generate the html docs, execute
+doxygen feature_mos_API_doxyfile
+
diff --git a/jni/feature_mos/doc/feature_mos_API_doxyfile b/jni/feature_mos/doc/feature_mos_API_doxyfile
new file mode 100755
index 0000000..dca8c8c
--- /dev/null
+++ b/jni/feature_mos/doc/feature_mos_API_doxyfile
@@ -0,0 +1,1557 @@
+# Doxyfile 1.6.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME =
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = .
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set
+# FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page. This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = ../src/mosaic/Mosaic.h
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.vhd \
+ *.vhdl
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
+# there is already a search function so this one should typically
+# be disabled.
+
+SEARCHENGINE = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/jni/feature_mos/src/mosaic/AlignFeatures.cpp b/jni/feature_mos/src/mosaic/AlignFeatures.cpp
new file mode 100644
index 0000000..a181dd8
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/AlignFeatures.cpp
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// AlignFeatures.cpp
+// S.O. # :
+// Author(s): zkira, mbansal, bsouthall, narodits
+// $Id: AlignFeatures.cpp,v 1.20 2011/06/17 13:35:47 mbansal Exp $
+
+#include <stdio.h>
+#include <string.h>
+
+#include "trsMatrix.h"
+#include "MatrixUtils.h"
+#include "AlignFeatures.h"
+
+Align::Align()
+{
+ width = height = 0;
+ frame_number = 0;
+ db_Identity3x3(Hcurr);
+}
+
+Align::~Align()
+{
+ // Free gray-scale image
+ if (imageGray != ImageUtils::IMAGE_TYPE_NOIMAGE)
+ ImageUtils::freeImage(imageGray);
+}
+
+char* Align::getRegProfileString()
+{
+ return reg.profile_string;
+}
+
+int Align::initialize(int width, int height, bool _quarter_res, float _thresh_still)
+{
+ int nr_corners = DEFAULT_NR_CORNERS;
+ double max_disparity = DEFAULT_MAX_DISPARITY;
+ int motion_model_type = DEFAULT_MOTION_MODEL;
+ int nrsamples = DB_DEFAULT_NR_SAMPLES;
+ double scale = DB_POINT_STANDARDDEV;
+ int chunk_size = DB_DEFAULT_CHUNK_SIZE;
+ int nrhorz = 20; // 1280/32 = 40
+ int nrvert = 12; // 720/30 = 24
+ bool linear_polish = false;
+ unsigned int reference_update_period = DEFAULT_REFERENCE_UPDATE_PERIOD;
+
+ const bool DEFAULT_USE_SMALLER_MATCHING_WINDOW = false;
+ bool use_smaller_matching_window = DEFAULT_USE_SMALLER_MATCHING_WINDOW;
+
+ quarter_res = _quarter_res;
+ thresh_still = _thresh_still;
+
+ frame_number = 0;
+ db_Identity3x3(Hcurr);
+ if (!reg.Initialized())
+ {
+ reg.Init(width,height,motion_model_type,20,linear_polish,quarter_res,scale,reference_update_period, false, 0, nrsamples,chunk_size,nr_corners,max_disparity,use_smaller_matching_window, nrhorz, nrvert);
+ }
+ this->width = width;
+ this->height = height;
+
+ imageGray = ImageUtils::allocateImage(width, height, 1);
+
+ if (reg.Initialized())
+ return ALIGN_RET_OK;
+ else
+ return ALIGN_RET_ERROR;
+}
+
+int Align::addFrameRGB(ImageType imageRGB)
+{
+ ImageUtils::rgb2gray(imageGray, imageRGB, width, height);
+ return addFrame(imageGray);
+}
+
+int Align::addFrame(ImageType imageGray_)
+{
+ // compute the homography:
+ double Hinv[9];
+ double Hinv33[3][3];
+ double Hprev33[3][3];
+ double Hcurr33[3][3];
+
+ // Obtain a vector of pointers to rows in image and pass in to dbreg
+ ImageType *m_rows = ImageUtils::imageTypeToRowPointers(imageGray_, width, height);
+ reg.AddFrame(m_rows, Hcurr);
+
+
+ if (frame_number != 0)
+ {
+
+ if(fabs(Hcurr[2])<thresh_still && fabs(Hcurr[5])<thresh_still) // Still camera
+ {
+ return ALIGN_RET_ERROR;
+ }
+
+ // Invert and multiple with previous transformation
+ Matrix33::convert9to33(Hcurr33, Hcurr);
+ Matrix33::convert9to33(Hprev33, Hprev);
+ //NormalizeProjMat(Hcurr33);
+ normProjMat33d(Hcurr33);
+
+ inv33d(Hcurr33, Hinv33);
+
+ mult33d(Hcurr33, Hprev33, Hinv33);
+ normProjMat33d(Hcurr33);
+ Matrix9::convert33to9(Hcurr, Hcurr33);
+
+ reg.UpdateReference(m_rows,quarter_res,false);
+ }
+
+ frame_number++;
+
+ // Copy curr to prev
+ memcpy(Happly, Hcurr, sizeof(double)*9);
+ memcpy(Hprev, Hcurr, sizeof(double)*9);
+
+ return ALIGN_RET_OK;
+}
+
+// Get current transformation
+int Align::getLastTRS(double trs[3][3])
+{
+ if (frame_number < 1)
+ {
+ fprintf(stderr, "Error: Align::getLastTRS called before a frame was processed\n");
+ return ALIGN_RET_ERROR;
+ }
+
+ Matrix33::convert9to33(trs, Happly);
+ return ALIGN_RET_OK;
+}
+
diff --git a/jni/feature_mos/src/mosaic/AlignFeatures.h b/jni/feature_mos/src/mosaic/AlignFeatures.h
new file mode 100644
index 0000000..06be596
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/AlignFeatures.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Align.h
+// S.O. # :
+// Author(s): zkira
+// $Id: AlignFeatures.h,v 1.13 2011/06/17 13:35:47 mbansal Exp $
+
+#ifndef ALIGN_H
+#define ALIGN_H
+
+#include "dbreg/dbreg.h"
+#include <db_utilities_camera.h>
+
+#include "ImageUtils.h"
+#include "MatrixUtils.h"
+
+class Align {
+
+public:
+ // Types of alignment possible
+ static const int ALIGN_TYPE_PAN = 1;
+
+ // Return codes
+ static const int ALIGN_RET_ERROR = -1;
+ static const int ALIGN_RET_OK = 0;
+
+ ///// Settings for feature-based alignment
+ // Number of features to use from corner detection
+ static const int DEFAULT_NR_CORNERS=750;
+ static const double DEFAULT_MAX_DISPARITY=0.1;//0.4;
+ // Type of homography to model
+ static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T;
+// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_PROJECTIVE;
+// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE;
+ static const unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number
+
+ Align();
+ ~Align();
+
+ // Initialization of structures, etc.
+ int initialize(int width, int height, bool quarter_res, float thresh_still);
+
+ // Add a frame. Note: The alignment computation is performed
+ // in this function
+ int addFrameRGB(ImageType image);
+ int addFrame(ImageType image);
+
+ // Obtain the TRS matrix from the last two frames
+ int getLastTRS(double trs[3][3]);
+ char* getRegProfileString();
+
+protected:
+
+ db_FrameToReferenceRegistration reg;
+
+ int frame_number;
+ double Happly[9]; // Homography to apply
+ double Hcurr[9]; // Homography from last frame
+ // (right now same as above)
+ double Hprev[9]; // Homography up until the last frame
+
+ int width,height;
+
+ bool quarter_res; // Whether to process at quarter resolution
+ float thresh_still; // Translation threshold in pixels to detect still camera
+ ImageType imageGray;
+};
+
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/Blend.cpp b/jni/feature_mos/src/mosaic/Blend.cpp
new file mode 100644
index 0000000..eb0275e
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Blend.cpp
@@ -0,0 +1,1000 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Blend.cpp
+// $Id: Blend.cpp,v 1.22 2011/06/24 04:22:14 mbansal Exp $
+
+#include <string.h>
+
+#include "Interp.h"
+#include "Blend.h"
+
+#include "Geometry.h"
+#include "trsMatrix.h"
+
+Blend::Blend()
+{
+ m_wb.blendingType = BLEND_TYPE_NONE;
+}
+
+Blend::~Blend()
+{
+ if (m_pFrameVPyr) free(m_pFrameVPyr);
+ if (m_pFrameUPyr) free(m_pFrameUPyr);
+ if (m_pFrameYPyr) free(m_pFrameYPyr);
+}
+
+int Blend::initialize(int blendingType, int frame_width, int frame_height)
+{
+ this->width = frame_width;
+ this->height = frame_height;
+ this->m_wb.blendingType = blendingType;
+
+ m_wb.blendRange = m_wb.blendRangeUV = BLEND_RANGE_DEFAULT;
+ m_wb.nlevs = m_wb.blendRange;
+ m_wb.nlevsC = m_wb.blendRangeUV;
+
+ if (m_wb.nlevs <= 0) m_wb.nlevs = 1; // Need levels for YUV processing
+ if (m_wb.nlevsC > m_wb.nlevs) m_wb.nlevsC = m_wb.nlevs;
+
+ m_wb.roundoffOverlap = 1.5;
+
+ m_pFrameYPyr = NULL;
+ m_pFrameUPyr = NULL;
+ m_pFrameVPyr = NULL;
+
+ m_pFrameYPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevs, (unsigned short) width, (unsigned short) height, BORDER);
+ m_pFrameUPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC, (unsigned short) (width), (unsigned short) (height), BORDER);
+ m_pFrameVPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC, (unsigned short) (width), (unsigned short) (height), BORDER);
+
+ if (!m_pFrameYPyr || !m_pFrameUPyr || !m_pFrameVPyr)
+ {
+ LOGIE("Error: Could not allocate pyramids for blending\n");
+ return BLEND_RET_ERROR_MEMORY;
+ }
+
+ return BLEND_RET_OK;
+}
+
+int Blend::runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight)
+{
+ int ret;
+ int numCenters;
+
+ ComputeBlendParameters(frames, frames_size, false);
+ numCenters = frames_size;
+
+ if (numCenters == 0)
+ {
+ LOGIE("Error: No frames to blend\n");
+ return BLEND_RET_ERROR;
+ }
+
+ if (!(m_AllSites = m_Triangulator.allocMemory(numCenters)))
+ {
+ return BLEND_RET_ERROR_MEMORY;
+ }
+
+ BlendRect global_rect;
+
+ global_rect.lft = global_rect.bot = 2e30; // min values
+ global_rect.rgt = global_rect.top = -2e30; // max values
+ MosaicFrame *mb = NULL;
+ double halfwidth = width / 2.0;
+ double halfheight = height / 2.0;
+
+ double z, x0, y0, x1, y1, x2, y2, x3, y3;
+
+ // Determine the extents of the final mosaic
+ CSite *csite = m_AllSites ;
+ for(int mfit = 0; mfit < frames_size; mfit++)
+ {
+ mb = frames[mfit];
+
+ // Compute clipping for this frame's rect
+ FrameToMosaicRect(mb->width, mb->height, mb->trs, mb->brect);
+ // Clip global rect using this frame's rect
+ ClipRect(mb->brect, global_rect);
+
+ // Calculate the corner points
+ FrameToMosaic(mb->trs, 0.0, 0.0, x0, y0);
+ FrameToMosaic(mb->trs, 0.0, mb->height-1.0, x1, y1);
+ FrameToMosaic(mb->trs, mb->width-1.0, mb->height-1.0, x2, y2);
+ FrameToMosaic(mb->trs, mb->width-1.0, 0.0, x3, y3);
+
+ // Compute the centroid of the warped region
+ FindQuadCentroid(x0, y0, x1, y1, x2, y2, x3, y3, csite->getVCenter().x, csite->getVCenter().y);
+
+ csite->setMb(mb);
+ csite++;
+ }
+
+ // Get origin and sizes
+ MosaicRect fullRect;
+
+ fullRect.left = (int) floor(global_rect.lft); // min-x
+ fullRect.top = (int) floor(global_rect.bot); // min-y
+ fullRect.right = (int) ceil(global_rect.rgt); // max-x
+ fullRect.bottom = (int) ceil(global_rect.top);// max-y
+ Mwidth = (unsigned short) (fullRect.right - fullRect.left + 1);
+ Mheight = (unsigned short) (fullRect.bottom - fullRect.top + 1);
+
+ // Make sure image width is multiple of 4
+ Mwidth = (unsigned short) ((Mwidth + 3) & ~3);
+ Mheight = (unsigned short) ((Mheight + 3) & ~3); // Round up.
+
+ if (Mwidth < width || Mheight < height)
+ {
+ LOGIE("RunBlend: aborting - consistency check failed, w=%d, h=%d\n", Mwidth, Mheight);
+ return BLEND_RET_ERROR;
+ }
+
+ YUVinfo *imgMos = YUVinfo::allocateImage(Mwidth, Mheight);
+ if (imgMos == NULL)
+ {
+ LOGIE("RunBlend: aborting - couldn't alloc %d x %d mosaic image\n", Mwidth, Mheight);
+ return BLEND_RET_ERROR_MEMORY;
+ }
+
+ // Set the Y image to 255 so we can distinguish when frame idx are written to it
+ memset(imgMos->Y.ptr[0], 255, (imgMos->Y.width * imgMos->Y.height));
+ // Set the v and u images to black
+ memset(imgMos->V.ptr[0], 128, (imgMos->V.width * imgMos->V.height) << 1);
+
+ // Do the triangulation. It returns a sorted list of edges
+ SEdgeVector *edge;
+ int n = m_Triangulator.triangulate(&edge, numCenters, width, height);
+ m_Triangulator.linkNeighbors(edge, n, numCenters);
+
+ MosaicRect cropping_rect;
+
+ // Do merging and blending :
+ ret = DoMergeAndBlend(frames, numCenters, width, height, *imgMos, fullRect, cropping_rect);
+
+ if (m_wb.blendingType == BLEND_TYPE_HORZ)
+ CropFinalMosaic(*imgMos, cropping_rect);
+
+
+ m_Triangulator.freeMemory(); // note: can be called even if delaunay_alloc() wasn't successful
+
+ imageMosaicYVU = imgMos->Y.ptr[0];
+
+
+ if (m_wb.blendingType == BLEND_TYPE_HORZ)
+ {
+ mosaicWidth = cropping_rect.right - cropping_rect.left + 1;
+ mosaicHeight = cropping_rect.bottom - cropping_rect.top + 1;
+ }
+ else
+ {
+ mosaicWidth = Mwidth;
+ mosaicHeight = Mheight;
+ }
+
+ return BLEND_RET_OK;
+}
+
+
+int Blend::FillFramePyramid(MosaicFrame *mb)
+{
+ ImageType mbY, mbU, mbV;
+ // Lay this image, centered into the temporary buffer
+ mbY = mb->image;
+ mbU = mb->getU();
+ mbV = mb->getV();
+
+ int h, w;
+
+ for(h=0; h<height; h++)
+ {
+ ImageTypeShort yptr = m_pFrameYPyr->ptr[h];
+ ImageTypeShort uptr = m_pFrameUPyr->ptr[h];
+ ImageTypeShort vptr = m_pFrameVPyr->ptr[h];
+
+ for(w=0; w<width; w++)
+ {
+ yptr[w] = (short) ((*(mbY++)) << 3);
+ uptr[w] = (short) ((*(mbU++)) << 3);
+ vptr[w] = (short) ((*(mbV++)) << 3);
+ }
+ }
+
+ // Spread the image through the border
+ PyramidShort::BorderSpread(m_pFrameYPyr, BORDER, BORDER, BORDER, BORDER);
+ PyramidShort::BorderSpread(m_pFrameUPyr, BORDER, BORDER, BORDER, BORDER);
+ PyramidShort::BorderSpread(m_pFrameVPyr, BORDER, BORDER, BORDER, BORDER);
+
+ // Generate Laplacian pyramids
+ if (!PyramidShort::BorderReduce(m_pFrameYPyr, m_wb.nlevs) || !PyramidShort::BorderExpand(m_pFrameYPyr, m_wb.nlevs, -1) ||
+ !PyramidShort::BorderReduce(m_pFrameUPyr, m_wb.nlevsC) || !PyramidShort::BorderExpand(m_pFrameUPyr, m_wb.nlevsC, -1) ||
+ !PyramidShort::BorderReduce(m_pFrameVPyr, m_wb.nlevsC) || !PyramidShort::BorderExpand(m_pFrameVPyr, m_wb.nlevsC, -1))
+ {
+ LOGIE("Error: Could not generate Laplacian pyramids\n");
+ return BLEND_RET_ERROR;
+ }
+ else
+ {
+ return BLEND_RET_OK;
+ }
+}
+
+int Blend::DoMergeAndBlend(MosaicFrame **frames, int nsite,
+ int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect)
+{
+ m_pMosaicYPyr = NULL;
+ m_pMosaicUPyr = NULL;
+ m_pMosaicVPyr = NULL;
+
+ m_pMosaicYPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevs,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
+ m_pMosaicUPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
+ m_pMosaicVPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
+ if (!m_pMosaicYPyr || !m_pMosaicUPyr || !m_pMosaicVPyr)
+ {
+ LOGIE("Error: Could not allocate pyramids for blending\n");
+ return BLEND_RET_ERROR_MEMORY;
+ }
+
+ MosaicFrame *mb;
+
+ CSite *esite = m_AllSites + nsite;
+ int site_idx;
+
+ // First go through each frame and for each mosaic pixel determine which frame it should come from
+ site_idx = 0;
+ for(CSite *csite = m_AllSites; csite < esite; csite++)
+ {
+ mb = csite->getMb();
+
+ mb->vcrect = mb->brect;
+ ClipBlendRect(csite, mb->vcrect);
+
+ ComputeMask(csite, mb->vcrect, mb->brect, rect, imgMos, site_idx);
+
+ site_idx++;
+ }
+
+ // Now perform the actual blending using the frame assignment determined above
+ site_idx = 0;
+ for(CSite *csite = m_AllSites; csite < esite; csite++)
+ {
+ mb = csite->getMb();
+
+
+ if(FillFramePyramid(mb)!=BLEND_RET_OK)
+ return BLEND_RET_ERROR;
+
+ ProcessPyramidForThisFrame(csite, mb->vcrect, mb->brect, rect, imgMos, mb->trs, site_idx);
+
+ site_idx++;
+ }
+
+
+ // Blend
+ PerformFinalBlending(imgMos, cropping_rect);
+
+ if (m_pMosaicVPyr) free(m_pMosaicVPyr);
+ if (m_pMosaicUPyr) free(m_pMosaicUPyr);
+ if (m_pMosaicYPyr) free(m_pMosaicYPyr);
+
+ return BLEND_RET_OK;
+}
+
+void Blend::CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect)
+{
+ int i, j, k;
+ ImageType yimg;
+ ImageType uimg;
+ ImageType vimg;
+
+
+ yimg = imgMos.Y.ptr[0];
+ uimg = imgMos.U.ptr[0];
+ vimg = imgMos.V.ptr[0];
+
+ k = 0;
+ for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
+ {
+ for (i = cropping_rect.left; i <= cropping_rect.right; i++)
+ {
+ yimg[k] = yimg[j*imgMos.Y.width+i];
+ k++;
+ }
+ }
+ for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
+ {
+ for (i = cropping_rect.left; i <= cropping_rect.right; i++)
+ {
+ yimg[k] = vimg[j*imgMos.Y.width+i];
+ k++;
+ }
+ }
+ for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
+ {
+ for (i = cropping_rect.left; i <= cropping_rect.right; i++)
+ {
+ yimg[k] = uimg[j*imgMos.Y.width+i];
+ k++;
+ }
+ }
+}
+
+int Blend::PerformFinalBlending(YUVinfo &imgMos, MosaicRect &cropping_rect)
+{
+ if (!PyramidShort::BorderExpand(m_pMosaicYPyr, m_wb.nlevs, 1) || !PyramidShort::BorderExpand(m_pMosaicUPyr, m_wb.nlevsC, 1) ||
+ !PyramidShort::BorderExpand(m_pMosaicVPyr, m_wb.nlevsC, 1))
+ {
+ LOGIE("Error: Could not BorderExpand!\n");
+ return BLEND_RET_ERROR;
+ }
+
+ ImageTypeShort myimg;
+ ImageTypeShort muimg;
+ ImageTypeShort mvimg;
+ ImageType yimg;
+ ImageType uimg;
+ ImageType vimg;
+
+ int cx = (int)imgMos.Y.width/2;
+ int cy = (int)imgMos.Y.height/2;
+
+ cropping_rect.left = 0;
+ cropping_rect.right = imgMos.Y.width-1;
+ cropping_rect.top = 0;
+ cropping_rect.bottom = imgMos.Y.height-1;
+
+ // Copy the resulting image into the full image using the mask
+ int i, j;
+
+ yimg = imgMos.Y.ptr[0];
+ uimg = imgMos.U.ptr[0];
+ vimg = imgMos.V.ptr[0];
+
+ for (j = 0; j < imgMos.Y.height; j++)
+ {
+ myimg = m_pMosaicYPyr->ptr[j];
+ muimg = m_pMosaicUPyr->ptr[j];
+ mvimg = m_pMosaicVPyr->ptr[j];
+
+ for (i = imgMos.Y.width; i--;)
+ {
+ // A final mask was set up previously,
+ // if the value is zero skip it, otherwise replace it.
+ if (*yimg <255)
+ {
+ short value = (short) ((*myimg) >> 3);
+ if (value < 0) value = 0;
+ else if (value > 255) value = 255;
+ *yimg = (unsigned char) value;
+
+ value = (short) ((*muimg) >> 3);
+ if (value < 0) value = 0;
+ else if (value > 255) value = 255;
+ *uimg = (unsigned char) value;
+
+ value = (short) ((*mvimg) >> 3);
+ if (value < 0) value = 0;
+ else if (value > 255) value = 255;
+ *vimg = (unsigned char) value;
+
+ }
+ else
+ { // set border color in here
+ *yimg = (unsigned char) 96;
+ }
+
+ yimg++;
+ uimg++;
+ vimg++;
+ myimg++;
+ muimg++;
+ mvimg++;
+ }
+ }
+
+ yimg = imgMos.Y.ptr[0];
+ uimg = imgMos.U.ptr[0];
+ vimg = imgMos.V.ptr[0];
+
+ int mincol = 0;
+ int maxcol = imgMos.Y.width-1;
+
+ const int MIN_X_FS = width*1/8;
+ const int MAX_X_FS = imgMos.Y.width - width*1/8;
+
+ for (j = 0; j < imgMos.Y.height; j++)
+ {
+ int minx = MIN_X_FS;
+ int maxx = MAX_X_FS;
+
+ for (i = 0; i < imgMos.Y.width; i++)
+ {
+ if(*yimg == 96 && *uimg == 128 && *vimg == 128)
+ {
+ }
+ else
+ {
+ if(i<minx)
+ minx = i;
+ if(i>maxx)
+ maxx = i;
+ }
+
+ yimg++;
+ uimg++;
+ vimg++;
+ }
+
+ // If we never touched the values, reset them to the image limits
+ if(minx == MIN_X_FS)
+ minx = 0;
+ if(maxx == MAX_X_FS)
+ maxx = imgMos.Y.width-1;
+
+ if(minx>mincol)
+ mincol = minx;
+ if(maxx<maxcol)
+ maxcol = maxx;
+ }
+
+ cropping_rect.left = mincol;
+ cropping_rect.right = maxcol;
+
+ // Crop rows
+ yimg = imgMos.Y.ptr[0];
+ uimg = imgMos.U.ptr[0];
+ vimg = imgMos.V.ptr[0];
+
+ int minrow = 0;
+ int maxrow = imgMos.Y.height-1;
+
+ const int MIN_Y_FS = height*1/8;
+ const int MAX_Y_FS = imgMos.Y.height - height*1/8;
+
+ for (i = 0; i < imgMos.Y.width; i++)
+ {
+ int miny = MIN_Y_FS;
+ int maxy = MAX_Y_FS;
+
+ for (j = 0; j < imgMos.Y.height; j++)
+ {
+ if(*yimg == 96 && *uimg == 128 && *vimg == 128)
+ {
+ }
+ else
+ {
+ if(j<miny)
+ miny = j;
+ if(j>maxy)
+ maxy = j;
+ }
+
+ yimg++;
+ uimg++;
+ vimg++;
+ }
+
+ // If we never touched the values, reset them to the image limits
+ if(miny == MIN_Y_FS)
+ miny = 0;
+ if(maxy == MAX_Y_FS)
+ maxy = imgMos.Y.height-1;
+
+ if(miny>minrow)
+ minrow = miny;
+ if(maxy<maxrow)
+ maxrow = maxy;
+ }
+
+ cropping_rect.top = minrow;
+ cropping_rect.bottom = maxrow;
+
+ return BLEND_RET_OK;
+}
+
+void Blend::ComputeMask(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, int site_idx)
+{
+ PyramidShort *dptr = m_pMosaicYPyr;
+
+ int nC = m_wb.nlevsC;
+ int l = (int) ((vcrect.lft - rect.left));
+ int b = (int) ((vcrect.bot - rect.top));
+ int r = (int) ((vcrect.rgt - rect.left));
+ int t = (int) ((vcrect.top - rect.top));
+
+ if (vcrect.lft == brect.lft)
+ l = (l <= 0) ? -BORDER : l - BORDER;
+ else if (l < -BORDER)
+ l = -BORDER;
+
+ if (vcrect.bot == brect.bot)
+ b = (b <= 0) ? -BORDER : b - BORDER;
+ else if (b < -BORDER)
+ b = -BORDER;
+
+ if (vcrect.rgt == brect.rgt)
+ r = (r >= dptr->width) ? dptr->width + BORDER - 1 : r + BORDER;
+ else if (r >= dptr->width + BORDER)
+ r = dptr->width + BORDER - 1;
+
+ if (vcrect.top == brect.top)
+ t = (t >= dptr->height) ? dptr->height + BORDER - 1 : t + BORDER;
+ else if (t >= dptr->height + BORDER)
+ t = dptr->height + BORDER - 1;
+
+ // Walk the Region of interest and populate the pyramid
+ for (int j = b; j <= t; j++)
+ {
+ int jj = j;
+ double sj = jj + rect.top;
+
+ for (int i = l; i <= r; i++)
+ {
+ int ii = i;
+ // project point and then triangulate to neighbors
+ double si = ii + rect.left;
+
+ double dself = hypotSq(csite->getVCenter().x - si, csite->getVCenter().y - sj);
+ int inMask = ((unsigned) ii < imgMos.Y.width &&
+ (unsigned) jj < imgMos.Y.height) ? 1 : 0;
+
+ if(!inMask)
+ continue;
+
+ // scan the neighbors to see if this is a valid position
+ unsigned char mask = (unsigned char) 255;
+ SEdgeVector *ce;
+ int ecnt;
+ for (ce = csite->getNeighbor(), ecnt = csite->getNumNeighbors(); ecnt--; ce++)
+ {
+ double d1 = hypotSq(m_AllSites[ce->second].getVCenter().x - si,
+ m_AllSites[ce->second].getVCenter().y - sj);
+ if (d1 < dself)
+ {
+ break;
+ }
+ }
+
+ if (ecnt >= 0) continue;
+
+ imgMos.Y.ptr[jj][ii] = (unsigned char)site_idx;
+ }
+ }
+}
+
+void Blend::ProcessPyramidForThisFrame(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, double trs[3][3], int site_idx)
+{
+ // Put the Region of interest (for all levels) into m_pMosaicYPyr
+ double inv_trs[3][3];
+ inv33d(trs, inv_trs);
+
+ // Process each pyramid level
+ PyramidShort *sptr = m_pFrameYPyr;
+ PyramidShort *suptr = m_pFrameUPyr;
+ PyramidShort *svptr = m_pFrameVPyr;
+
+ PyramidShort *dptr = m_pMosaicYPyr;
+ PyramidShort *duptr = m_pMosaicUPyr;
+ PyramidShort *dvptr = m_pMosaicVPyr;
+
+ int dscale = 0; // distance scale for the current level
+ int nC = m_wb.nlevsC;
+ for (int n = m_wb.nlevs; n--; dscale++, dptr++, sptr++, dvptr++, duptr++, svptr++, suptr++, nC--)
+ {
+ int l = (int) ((vcrect.lft - rect.left) / (1 << dscale));
+ int b = (int) ((vcrect.bot - rect.top) / (1 << dscale));
+ int r = (int) ((vcrect.rgt - rect.left) / (1 << dscale) + .5);
+ int t = (int) ((vcrect.top - rect.top) / (1 << dscale) + .5);
+
+ if (vcrect.lft == brect.lft)
+ l = (l <= 0) ? -BORDER : l - BORDER;
+ else if (l < -BORDER)
+ l = -BORDER;
+
+ if (vcrect.bot == brect.bot)
+ b = (b <= 0) ? -BORDER : b - BORDER;
+ else if (b < -BORDER)
+ b = -BORDER;
+
+ if (vcrect.rgt == brect.rgt)
+ r = (r >= dptr->width) ? dptr->width + BORDER - 1 : r + BORDER;
+ else if (r >= dptr->width + BORDER)
+ r = dptr->width + BORDER - 1;
+
+ if (vcrect.top == brect.top)
+ t = (t >= dptr->height) ? dptr->height + BORDER - 1 : t + BORDER;
+ else if (t >= dptr->height + BORDER)
+ t = dptr->height + BORDER - 1;
+
+ // Walk the Region of interest and populate the pyramid
+ for (int j = b; j <= t; j++)
+ {
+ int jj = (j << dscale);
+ double sj = jj + rect.top;
+
+ for (int i = l; i <= r; i++)
+ {
+ int ii = (i << dscale);
+ // project point and then triangulate to neighbors
+ double si = ii + rect.left;
+
+ int inMask = ((unsigned) ii < imgMos.Y.width &&
+ (unsigned) jj < imgMos.Y.height) ? 1 : 0;
+
+ if(inMask && imgMos.Y.ptr[jj][ii]!=site_idx && imgMos.Y.ptr[jj][ii]!=255)
+ continue;
+
+ // Project this mosaic point into the original frame coordinate space
+ double xx, yy;
+
+ MosaicToFrame(inv_trs, si, sj, xx, yy);
+
+ if (xx < 0.0 || yy < 0.0 || xx > width - 1.0 || yy > height - 1.0)
+ {
+ if(inMask)
+ {
+ imgMos.Y.ptr[jj][ii] = 255;
+ }
+ }
+
+ xx /= (1 << dscale);
+ yy /= (1 << dscale);
+
+
+ int x1 = (xx >= 0.0) ? (int) xx : (int) floor(xx);
+ int y1 = (yy >= 0.0) ? (int) yy : (int) floor(yy);
+
+ // Final destination in extended pyramid
+#ifndef LINEAR_INTERP
+ if(inSegment(x1, sptr->width, BORDER-1) && inSegment(y1, sptr->height, BORDER-1))
+ {
+ double xfrac = xx - x1;
+ double yfrac = yy - y1;
+ dptr->ptr[j][i] = (short) (.5 + ciCalc(sptr, x1, y1, xfrac, yfrac));
+ if (dvptr >= m_pMosaicVPyr && nC > 0)
+ {
+ duptr->ptr[j][i] = (short) (.5 + ciCalc(suptr, x1, y1, xfrac, yfrac));
+ dvptr->ptr[j][i] = (short) (.5 + ciCalc(svptr, x1, y1, xfrac, yfrac));
+ }
+ }
+#else
+ if(inSegment(x1, sptr->width, BORDER) && inSegment(y1, sptr->height, BORDER))
+ {
+ int x2 = x1 + 1;
+ int y2 = y1 + 1;
+ double xfrac = xx - x1;
+ double yfrac = yy - y1;
+ double y1val = sptr->ptr[y1][x1] +
+ (sptr->ptr[y1][x2] - sptr->ptr[y1][x1]) * xfrac;
+ double y2val = sptr->ptr[y2][x1] +
+ (sptr->ptr[y2][x2] - sptr->ptr[y2][x1]) * xfrac;
+ dptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
+
+ if (dvptr >= m_pMosaicVPyr && nC > 0)
+ {
+ y1val = suptr->ptr[y1][x1] +
+ (suptr->ptr[y1][x2] - suptr->ptr[y1][x1]) * xfrac;
+ y2val = suptr->ptr[y2][x1] +
+ (suptr->ptr[y2][x2] - suptr->ptr[y2][x1]) * xfrac;
+
+ duptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
+
+ y1val = svptr->ptr[y1][x1] +
+ (svptr->ptr[y1][x2] - svptr->ptr[y1][x1]) * xfrac;
+ y2val = svptr->ptr[y2][x1] +
+ (svptr->ptr[y2][x2] - svptr->ptr[y2][x1]) * xfrac;
+
+ dvptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
+ }
+ }
+#endif
+ else
+ {
+ clipToSegment(x1, sptr->width, BORDER);
+ clipToSegment(y1, sptr->height, BORDER);
+
+ dptr->ptr[j][i] = sptr->ptr[y1][x1];
+ if (dvptr >= m_pMosaicVPyr && nC > 0)
+ {
+ dvptr->ptr[j][i] = svptr->ptr[y1][x1];
+ duptr->ptr[j][i] = suptr->ptr[y1][x1];
+ }
+ }
+ }
+ }
+ }
+}
+
+void Blend::MosaicToFrame(double trs[3][3], double x, double y, double &wx, double &wy)
+{
+ double X, Y, z;
+ if (m_wb.theta == 0.0)
+ {
+ X = x;
+ Y = y;
+ }
+ else if (m_wb.horizontal)
+ {
+ double alpha = x * m_wb.direction / m_wb.width;
+ double length = (y - alpha * m_wb.correction) * m_wb.direction + m_wb.radius;
+ double deltaTheta = m_wb.theta * alpha;
+ double sinTheta = sin(deltaTheta);
+ double cosTheta = sqrt(1.0 - sinTheta * sinTheta) * m_wb.direction;
+ X = length * sinTheta + m_wb.x;
+ Y = length * cosTheta + m_wb.y;
+ }
+ else
+ {
+ double alpha = y * m_wb.direction / m_wb.width;
+ double length = (x - alpha * m_wb.correction) * m_wb.direction + m_wb.radius;
+ double deltaTheta = m_wb.theta * alpha;
+ double sinTheta = sin(deltaTheta);
+ double cosTheta = sqrt(1.0 - sinTheta * sinTheta) * m_wb.direction;
+ Y = length * sinTheta + m_wb.y;
+ X = length * cosTheta + m_wb.x;
+ }
+ z = ProjZ(trs, X, Y, 1.0);
+ wx = ProjX(trs, X, Y, z, 1.0);
+ wy = ProjY(trs, X, Y, z, 1.0);
+}
+
+void Blend::FrameToMosaic(double trs[3][3], double x, double y, double &wx, double &wy)
+{
+ // Project into the intermediate Mosaic coordinate system
+ double z = ProjZ(trs, x, y, 1.0);
+ double X = ProjX(trs, x, y, z, 1.0);
+ double Y = ProjY(trs, x, y, z, 1.0);
+
+ if (m_wb.theta == 0.0)
+ {
+ // No rotation, then this is all we need to do.
+ wx = X;
+ wy = Y;
+ }
+ else if (m_wb.horizontal)
+ {
+ double deltaX = X - m_wb.x;
+ double deltaY = Y - m_wb.y;
+ double length = sqrt(deltaX * deltaX + deltaY * deltaY);
+ double deltaTheta = asin(deltaX / length);
+ double alpha = deltaTheta / m_wb.theta;
+ wx = alpha * m_wb.width * m_wb.direction;
+ wy = (length - m_wb.radius) * m_wb.direction + alpha * m_wb.correction;
+ }
+ else
+ {
+ double deltaX = X - m_wb.x;
+ double deltaY = Y - m_wb.y;
+ double length = sqrt(deltaX * deltaX + deltaY * deltaY);
+ double deltaTheta = asin(deltaY / length);
+ double alpha = deltaTheta / m_wb.theta;
+ wy = alpha * m_wb.width * m_wb.direction;
+ wx = (length - m_wb.radius) * m_wb.direction + alpha * m_wb.correction;
+ }
+}
+
+
+
+// Clip the region of interest as small as possible by using the Voronoi edges of
+// the neighbors
+void Blend::ClipBlendRect(CSite *csite, BlendRect &brect)
+{
+ SEdgeVector *ce;
+ int ecnt;
+ for (ce = csite->getNeighbor(), ecnt = csite->getNumNeighbors(); ecnt--; ce++)
+ {
+ // calculate the Voronoi bisector intersection
+ const double epsilon = 1e-5;
+ double dx = (m_AllSites[ce->second].getVCenter().x - m_AllSites[ce->first].getVCenter().x);
+ double dy = (m_AllSites[ce->second].getVCenter().y - m_AllSites[ce->first].getVCenter().y);
+ double xmid = m_AllSites[ce->first].getVCenter().x + dx/2.0;
+ double ymid = m_AllSites[ce->first].getVCenter().y + dy/2.0;
+ double inter;
+
+ if (dx > epsilon)
+ {
+ // neighbor is on right
+ if ((inter = m_wb.roundoffOverlap + xmid - dy * (((dy >= 0.0) ? brect.bot : brect.top) - ymid) / dx) < brect.rgt)
+ brect.rgt = inter;
+ }
+ else if (dx < -epsilon)
+ {
+ // neighbor is on left
+ if ((inter = -m_wb.roundoffOverlap + xmid - dy * (((dy >= 0.0) ? brect.bot : brect.top) - ymid) / dx) > brect.lft)
+ brect.lft = inter;
+ }
+ if (dy > epsilon)
+ {
+ // neighbor is above
+ if ((inter = m_wb.roundoffOverlap + ymid - dx * (((dx >= 0.0) ? brect.lft : brect.rgt) - xmid) / dy) < brect.top)
+ brect.top = inter;
+ }
+ else if (dy < -epsilon)
+ {
+ // neighbor is below
+ if ((inter = -m_wb.roundoffOverlap + ymid - dx * (((dx >= 0.0) ? brect.lft : brect.rgt) - xmid) / dy) > brect.bot)
+ brect.bot = inter;
+ }
+ }
+}
+
+void Blend::FrameToMosaicRect(int width, int height, double trs[3][3], BlendRect &brect)
+{
+ // We need to walk the perimeter since the borders can be bent.
+ brect.lft = brect.bot = 2e30;
+ brect.rgt = brect.top = -2e30;
+ double xpos, ypos;
+ double lasty = height - 1.0;
+ double lastx = width - 1.0;
+ int i;
+
+ for (i = width; i--;)
+ {
+
+ FrameToMosaic(trs, (double) i, 0.0, xpos, ypos);
+ ClipRect(xpos, ypos, brect);
+ FrameToMosaic(trs, (double) i, lasty, xpos, ypos);
+ ClipRect(xpos, ypos, brect);
+ }
+ for (i = height; i--;)
+ {
+ FrameToMosaic(trs, 0.0, (double) i, xpos, ypos);
+ ClipRect(xpos, ypos, brect);
+ FrameToMosaic(trs, lastx, (double) i, xpos, ypos);
+ ClipRect(xpos, ypos, brect);
+ }
+}
+
+
+
+void Blend::ComputeBlendParameters(MosaicFrame **frames, int frames_size, int is360)
+{
+ if (m_wb.blendingType != BLEND_TYPE_CYLPAN && m_wb.blendingType != BLEND_TYPE_HORZ)
+ {
+ m_wb.theta = 0.0;
+ return;
+ }
+
+ MosaicFrame *first = frames[0];
+ MosaicFrame *last = frames[frames_size-1];
+ MosaicFrame *mb;
+
+ double lxpos = last->trs[0][2], lypos = last->trs[1][5];
+ double fxpos = first->trs[0][2], fypos = first->trs[1][5];
+
+ // Calculate warp to produce proper stitching.
+ // get x, y displacement
+ double midX = last->width / 2.0;
+ double midY = last->height / 2.0;
+ double z = ProjZ(first->trs, midX, midY, 1.0);
+ double firstX, firstY;
+ double prevX = firstX = ProjX(first->trs, midX, midY, z, 1.0);
+ double prevY = firstY = ProjY(first->trs, midX, midY, z, 1.0);
+
+ double arcLength, lastTheta;
+ m_wb.theta = lastTheta = arcLength = 0.0;
+ for (int i = 0; i < frames_size; i++)
+ {
+ mb = frames[i];
+ double currX, currY;
+ z = ProjZ(mb->trs, midX, midY, 1.0);
+ currX = ProjX(mb->trs, midX, midY, z, 1.0);
+ currY = ProjY(mb->trs, midX, midY, z, 1.0);
+ double deltaX = currX - prevX;
+ double deltaY = currY - prevY;
+ arcLength += sqrt(deltaY * deltaY + deltaX * deltaX);
+ if (!is360)
+ {
+ double thisTheta = asin(mb->trs[1][0]);
+ m_wb.theta += thisTheta - lastTheta;
+ lastTheta = thisTheta;
+ }
+ prevX = currX;
+ prevY = currY;
+ }
+
+ // In case of BMP output, stretch this to end at the proper alignment
+ m_wb.width = arcLength;
+ if (is360) m_wb.theta = asin(last->trs[1][0]);
+
+ // If there is no rotation, we're done.
+ if (m_wb.theta != 0.0)
+ {
+ double dx = prevX - firstX;
+ double dy = prevY - firstY;
+ if (abs(lxpos - fxpos) > abs(lypos - fypos))
+ {
+ m_wb.horizontal = 1;
+ // Calculate radius position to make ends exactly the same Y offset
+ double radiusTheta = dx / cos(3.14159 / 2.0 - m_wb.theta);
+ m_wb.radius = dy + radiusTheta * cos(m_wb.theta);
+ if (m_wb.radius < 0.0) m_wb.radius = -m_wb.radius;
+ }
+ else
+ {
+ m_wb.horizontal = 0;
+ // Calculate radius position to make ends exactly the same Y offset
+ double radiusTheta = dy / cos(3.14159 / 2.0 - m_wb.theta);
+ m_wb.radius = dx + radiusTheta * cos(m_wb.theta);
+ if (m_wb.radius < 0.0) m_wb.radius = -m_wb.radius;
+ }
+
+ // Determine major direction
+ if (m_wb.horizontal)
+ {
+ // Horizontal strip
+ if (is360) m_wb.x = firstX;
+ else
+ {
+ if (lxpos - fxpos < 0)
+ {
+ m_wb.x = firstX + midX;
+ z = ProjZ(last->trs, 0.0, midY, 1.0);
+ prevX = ProjX(last->trs, 0.0, midY, z, 1.0);
+ prevY = ProjY(last->trs, 0.0, midY, z, 1.0);
+ }
+ else
+ {
+ m_wb.x = firstX - midX;
+ z = ProjZ(last->trs, last->width - 1.0, midY, 1.0);
+ prevX = ProjX(last->trs, last->width - 1.0, midY, z, 1.0);
+ prevY = ProjY(last->trs, last->width - 1.0, midY, z, 1.0);
+ }
+ }
+ dy = prevY - firstY;
+ if (dy < 0.0) m_wb.direction = 1.0;
+ else m_wb.direction = -1.0;
+ m_wb.y = firstY - m_wb.radius * m_wb.direction;
+ if (dy * m_wb.theta > 0.0) m_wb.width = -m_wb.width;
+ }
+ else
+ {
+ // Vertical strip
+ if (is360) m_wb.y = firstY;
+ else
+ {
+ if (lypos - fypos < 0)
+ {
+ m_wb.x = firstY + midY;
+ z = ProjZ(last->trs, midX, 0.0, 1.0);
+ prevX = ProjX(last->trs, midX, 0.0, z, 1.0);
+ prevY = ProjY(last->trs, midX, 0.0, z, 1.0);
+ }
+ else
+ {
+ m_wb.x = firstX - midX;
+ z = ProjZ(last->trs, midX, last->height - 1.0, 1.0);
+ prevX = ProjX(last->trs, midX, last->height - 1.0, z, 1.0);
+ prevY = ProjY(last->trs, midX, last->height - 1.0, z, 1.0);
+ }
+ }
+ dx = prevX - firstX;
+ if (dx < 0.0) m_wb.direction = 1.0;
+ else m_wb.direction = -1.0;
+ m_wb.x = firstX - m_wb.radius * m_wb.direction;
+ if (dx * m_wb.theta > 0.0) m_wb.width = -m_wb.width;
+ }
+
+ // Calculate the correct correction factor
+ double deltaX = prevX - m_wb.x;
+ double deltaY = prevY - m_wb.y;
+ double length = sqrt(deltaX * deltaX + deltaY * deltaY);
+ double deltaTheta = (m_wb.horizontal) ? deltaX : deltaY;
+ deltaTheta = asin(deltaTheta / length);
+ m_wb.correction = ((m_wb.radius - length) * m_wb.direction) /
+ (deltaTheta / m_wb.theta);
+ }
+}
diff --git a/jni/feature_mos/src/mosaic/Blend.h b/jni/feature_mos/src/mosaic/Blend.h
new file mode 100644
index 0000000..9998aa6
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Blend.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Blend.h
+// $Id: Blend.h,v 1.23 2011/06/24 04:22:14 mbansal Exp $
+
+#ifndef BLEND_H
+#define BLEND_H
+
+#include "MosaicTypes.h"
+#include "Pyramid.h"
+
+#include "Delaunay.h"
+
+#define BLEND_RANGE_DEFAULT 6
+#define BORDER 8
+
+//#define LINEAR_INTERP
+
+//#define LOGII(...) //
+//#define LOGIE(...) //
+#if 1
+#ifdef ANDROID
+#include <android/log.h>
+#define ANDROID_LOG_VERBOSE ANDROID_LOG_DEBUG
+#define LOG_TAG "CVJNI"
+#define LOGV(...) __android_log_print(ANDROID_LOG_SILENT, LOG_TAG, __VA_ARGS__)
+#define LOGII(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define LOGIE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+#else
+#define LOGII printf
+#define LOGIE printf
+#endif
+#endif
+
+
+/**
+ * Class for pyramid blending a mosaic.
+ */
+class Blend {
+
+public:
+
+ static const int BLEND_TYPE_NONE = -1;
+ static const int BLEND_TYPE_FULL = 0;
+ static const int BLEND_TYPE_PAN = 1;
+ static const int BLEND_TYPE_CYLPAN = 2;
+ static const int BLEND_TYPE_HORZ = 3;
+
+ static const int BLEND_RET_ERROR = -1;
+ static const int BLEND_RET_OK = 0;
+ static const int BLEND_RET_ERROR_MEMORY = 1;
+
+ Blend();
+ ~Blend();
+
+ int initialize(int blendingType, int frame_width, int frame_height);
+
+ int runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight);
+
+protected:
+
+ PyramidShort *m_pFrameYPyr;
+ PyramidShort *m_pFrameUPyr;
+ PyramidShort *m_pFrameVPyr;
+
+ PyramidShort *m_pMosaicYPyr;
+ PyramidShort *m_pMosaicUPyr;
+ PyramidShort *m_pMosaicVPyr;
+
+ CDelaunay m_Triangulator;
+ CSite *m_AllSites;
+
+ BlendParams m_wb;
+
+ // Height and width of individual frames
+ int width, height;
+
+ // Height and width of mosaic
+ unsigned short Mwidth, Mheight;
+
+ // Helper functions
+ void FrameToMosaic(double trs[3][3], double x, double y, double &wx, double &wy);
+ void MosaicToFrame(double trs[3][3], double x, double y, double &wx, double &wy);
+ void FrameToMosaicRect(int width, int height, double trs[3][3], BlendRect &brect);
+ void ClipBlendRect(CSite *csite, BlendRect &brect);
+
+ int DoMergeAndBlend(MosaicFrame **frames, int nsite, int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect);
+ void ComputeMask(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, int site_idx);
+ void ProcessPyramidForThisFrame(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, double trs[3][3], int site_idx);
+
+ int FillFramePyramid(MosaicFrame *mb);
+ void ComputeBlendParameters(MosaicFrame **frames, int frames_size, int is360);
+
+ int PerformFinalBlending(YUVinfo &imgMos, MosaicRect &cropping_rect);
+ void CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect);
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/CSite.h b/jni/feature_mos/src/mosaic/CSite.h
new file mode 100644
index 0000000..928c173
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/CSite.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// CSite.h
+// $Id: CSite.h,v 1.3 2011/06/17 13:35:47 mbansal Exp $
+
+#ifndef TRIDEL_H
+#define TRIDEL_H
+
+#include "MosaicTypes.h"
+
+typedef struct
+{
+ short first;
+ short second;
+} SEdgeVector;
+
+typedef struct
+{
+ double x;
+ double y;
+} SVec2d;
+
+class CSite
+{
+private:
+ MosaicFrame *mosaicFrame;
+ SEdgeVector *neighbor;
+ int numNeighbors;
+ SVec2d voronoiCenter;
+
+public:
+ CSite();
+ ~CSite();
+
+ inline MosaicFrame* getMb() { return mosaicFrame; }
+ inline SEdgeVector* getNeighbor() { return neighbor; }
+ inline int getNumNeighbors() { return numNeighbors; }
+ inline SVec2d& getVCenter() { return voronoiCenter; }
+ inline double X() { return voronoiCenter.x; }
+ inline double Y() { return voronoiCenter.y; }
+
+ inline void incrNumNeighbors() { numNeighbors++; }
+ inline void setNumNeighbors(int num) { numNeighbors = num; }
+ inline void setNeighbor(SEdgeVector *nb) { neighbor = nb; }
+ inline void setMb(MosaicFrame *mb) { mosaicFrame = mb; }
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/Delaunay.cpp b/jni/feature_mos/src/mosaic/Delaunay.cpp
new file mode 100644
index 0000000..0ce09fc
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Delaunay.cpp
@@ -0,0 +1,633 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Delaunay.cpp
+// $Id: Delaunay.cpp,v 1.10 2011/06/17 13:35:48 mbansal Exp $
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include "Delaunay.h"
+
+#define QQ 9 // Optimal value as determined by testing
+#define DM 38 // 2^(1+DM/2) element sort capability. DM=38 for >10^6 elements
+#define NYL -1
+#define valid(l) ccw(orig(basel), dest(l), dest(basel))
+
+
+CDelaunay::CDelaunay()
+{
+}
+
+CDelaunay::~CDelaunay()
+{
+}
+
+// Allocate storage, construct triangulation, compute voronoi corners
+int CDelaunay::triangulate(SEdgeVector **edges, int n_sites, int width, int height)
+{
+ EdgePointer cep;
+
+ deleteAllEdges();
+ buildTriangulation(n_sites);
+ cep = consolidateEdges();
+ *edges = ev;
+
+ // Note: construction_list will change ev
+ return constructList(cep, width, height);
+}
+
+// builds delaunay triangulation
+void CDelaunay::buildTriangulation(int size)
+{
+ int i, rows;
+ EdgePointer lefte, righte;
+
+ rows = (int)( 0.5 + sqrt( (double) size / log( (double) size )));
+
+ // Sort the pointers by x-coordinate of site
+ for ( i=0 ; i < size ; i++ ) {
+ sp[i] = (SitePointer) i;
+ }
+
+ spsortx( sp, 0, size-1 );
+ build( 0, size-1, &lefte, &righte, rows );
+ oneBndryEdge = lefte;
+}
+
+// Recursive Delaunay Triangulation Procedure
+// Contains modifications for axis-switching division.
+void CDelaunay::build(int lo, int hi, EdgePointer *le, EdgePointer *re, int rows)
+{
+ EdgePointer a, b, c, ldo, rdi, ldi, rdo, maxx, minx;
+ int split, lowrows;
+ int low, high;
+ SitePointer s1, s2, s3;
+ low = lo;
+ high = hi;
+
+ if ( low < (high-2) ) {
+ // more than three elements; do recursion
+ minx = sp[low];
+ maxx = sp[high];
+ if (rows == 1) { // time to switch axis of division
+ spsorty( sp, low, high);
+ rows = 65536;
+ }
+ lowrows = rows/2;
+ split = low - 1 + (int)
+ (0.5 + ((double)(high-low+1) * ((double)lowrows / (double)rows)));
+ build( low, split, &ldo, &ldi, lowrows );
+ build( split+1, high, &rdi, &rdo, (rows-lowrows) );
+ doMerge(&ldo, ldi, rdi, &rdo);
+ while (orig(ldo) != minx) {
+ ldo = rprev(ldo);
+ }
+ while (orig(rdo) != maxx) {
+ rdo = (SitePointer) lprev(rdo);
+ }
+ *le = ldo;
+ *re = rdo;
+ }
+ else if (low >= (high - 1)) { // two or one points
+ a = makeEdge(sp[low], sp[high]);
+ *le = a;
+ *re = (EdgePointer) sym(a);
+ } else { // three points
+ // 3 cases: triangles of 2 orientations, and 3 points on a line
+ a = makeEdge((s1 = sp[low]), (s2 = sp[low+1]));
+ b = makeEdge(s2, (s3 = sp[high]));
+ splice((EdgePointer) sym(a), b);
+ if (ccw(s1, s3, s2)) {
+ c = connectLeft(b, a);
+ *le = (EdgePointer) sym(c);
+ *re = c;
+ } else {
+ *le = a;
+ *re = (EdgePointer) sym(b);
+ if (ccw(s1, s2, s3)) {
+ // not colinear
+ c = connectLeft(b, a);
+ }
+ }
+ }
+}
+
+// Quad-edge manipulation primitives
+EdgePointer CDelaunay::makeEdge(SitePointer origin, SitePointer destination)
+{
+ EdgePointer temp, ans;
+ temp = allocEdge();
+ ans = temp;
+
+ onext(temp) = ans;
+ orig(temp) = origin;
+ onext(++temp) = (EdgePointer) (ans + 3);
+ onext(++temp) = (EdgePointer) (ans + 2);
+ orig(temp) = destination;
+ onext(++temp) = (EdgePointer) (ans + 1);
+
+ return(ans);
+}
+
+void CDelaunay::splice(EdgePointer a, EdgePointer b)
+{
+ EdgePointer alpha, beta, temp;
+ alpha = (EdgePointer) rot(onext(a));
+ beta = (EdgePointer) rot(onext(b));
+ temp = onext(alpha);
+ onext(alpha) = onext(beta);
+ onext(beta) = temp;
+ temp = onext(a);
+ onext(a) = onext(b);
+ onext(b) = temp;
+}
+
+EdgePointer CDelaunay::connectLeft(EdgePointer a, EdgePointer b)
+{
+ EdgePointer ans;
+ ans = makeEdge(dest(a), orig(b));
+ splice(ans, (EdgePointer) lnext(a));
+ splice((EdgePointer) sym(ans), b);
+ return(ans);
+}
+
+EdgePointer CDelaunay::connectRight(EdgePointer a, EdgePointer b)
+{
+ EdgePointer ans;
+ ans = makeEdge(dest(a), orig(b));
+ splice(ans, (EdgePointer) sym(a));
+ splice((EdgePointer) sym(ans), (EdgePointer) oprev(b));
+ return(ans);
+}
+
+// disconnects e from the rest of the structure and destroys it
+void CDelaunay::deleteEdge(EdgePointer e)
+{
+ splice(e, (EdgePointer) oprev(e));
+ splice((EdgePointer) sym(e), (EdgePointer) oprev(sym(e)));
+ freeEdge(e);
+}
+
+//
+// Overall storage allocation
+//
+
+// Quad-edge storage allocation
+CSite *CDelaunay::allocMemory(int n)
+{
+ unsigned int size;
+
+ size = ((sizeof(CSite) + sizeof(SitePointer)) * n +
+ (sizeof(SitePointer) + sizeof(EdgePointer)) * 12
+ ) * n;
+ if (!(sa = (CSite*) malloc(size))) {
+ return NULL;
+ }
+ sp = (SitePointer *) (sa + n);
+ ev = (SEdgeVector *) (org = sp + n);
+ next = (EdgePointer *) (org + 12 * n);
+ ei = (struct EDGE_INFO *) (next + 12 * n);
+ return sa;
+}
+
+void CDelaunay::freeMemory()
+{
+ if (sa) {
+ free(sa);
+ sa = (CSite*)NULL;
+ }
+}
+
+//
+// Edge storage management
+//
+
+void CDelaunay::deleteAllEdges()
+{
+ nextEdge = 0;
+ availEdge = NYL;
+}
+
+EdgePointer CDelaunay::allocEdge()
+{
+ EdgePointer ans;
+
+ if (availEdge == NYL) {
+ ans = nextEdge, nextEdge += 4;
+ } else {
+ ans = availEdge, availEdge = onext(availEdge);
+ }
+ return(ans);
+}
+
+void CDelaunay::freeEdge(EdgePointer e)
+{
+ e ^= e & 3;
+ onext(e) = availEdge;
+ availEdge = e;
+}
+
+EdgePointer CDelaunay::consolidateEdges()
+{
+ EdgePointer e;
+ int i,j;
+
+ while (availEdge != NYL) {
+ nextEdge -= 4; e = availEdge; availEdge = onext(availEdge);
+
+ if (e==nextEdge) {
+ continue; // the one deleted was the last one anyway
+ }
+ if ((oneBndryEdge&~3) == nextEdge) {
+ oneBndryEdge = (EdgePointer) (e | (oneBndryEdge&3));
+ }
+ for (i=0,j=3; i<4; i++,j=rot(j)) {
+ onext(e+i) = onext(nextEdge+i);
+ onext(rot(onext(e+i))) = (EdgePointer) (e+j);
+ }
+ }
+ return nextEdge;
+}
+
+//
+// Sorting Routines
+//
+
+int CDelaunay::xcmpsp(int i, int j)
+{
+ double d = sa[(i>=0)?sp[i]:sp1].X() - sa[(j>=0)?sp[j]:sp1].X();
+ if ( d > 0. ) {
+ return 1;
+ }
+ if ( d < 0. ) {
+ return -1;
+ }
+ d = sa[(i>=0)?sp[i]:sp1].Y() - sa[(j>=0)?sp[j]:sp1].Y();
+ if ( d > 0. ) {
+ return 1;
+ }
+ if ( d < 0. ) {
+ return -1;
+ }
+ return 0;
+}
+
+int CDelaunay::ycmpsp(int i, int j)
+{
+ double d = sa[(i>=0)?sp[i]:sp1].Y() - sa[(j>=0)?sp[j]:sp1].Y();
+ if ( d > 0. ) {
+ return 1;
+ }
+ if ( d < 0. ) {
+ return -1;
+ }
+ d = sa[(i>=0)?sp[i]:sp1].X() - sa[(j>=0)?sp[j]:sp1].X();
+ if ( d > 0. ) {
+ return 1;
+ }
+ if ( d < 0. ) {
+ return -1;
+ }
+ return 0;
+}
+
+int CDelaunay::cmpev(int i, int j)
+{
+ return (ev[i].first - ev[j].first);
+}
+
+void CDelaunay::swapsp(int i, int j)
+{
+ int t;
+ t = (i>=0) ? sp[i] : sp1;
+
+ if (i>=0) {
+ sp[i] = (j>=0)?sp[j]:sp1;
+ } else {
+ sp1 = (j>=0)?sp[j]:sp1;
+ }
+
+ if (j>=0) {
+ sp[j] = (SitePointer) t;
+ } else {
+ sp1 = (SitePointer) t;
+ }
+}
+
+void CDelaunay::swapev(int i, int j)
+{
+ SEdgeVector temp;
+
+ temp = ev[i];
+ ev[i] = ev[j];
+ ev[j] = temp;
+}
+
+void CDelaunay::copysp(int i, int j)
+{
+ if (j>=0) {
+ sp[j] = (i>=0)?sp[i]:sp1;
+ } else {
+ sp1 = (i>=0)?sp[i]:sp1;
+ }
+}
+
+void CDelaunay::copyev(int i, int j)
+{
+ ev[j] = ev[i];
+}
+
+void CDelaunay::spsortx(SitePointer *sp_in, int low, int high)
+{
+ sp = sp_in;
+ rcssort(low,high,-1,&CDelaunay::xcmpsp,&CDelaunay::swapsp,&CDelaunay::copysp);
+}
+
+void CDelaunay::spsorty(SitePointer *sp_in, int low, int high )
+{
+ sp = sp_in;
+ rcssort(low,high,-1,&CDelaunay::ycmpsp,&CDelaunay::swapsp,&CDelaunay::copysp);
+}
+
+void CDelaunay::rcssort(int lowelt, int highelt, int temp,
+ int (CDelaunay::*comparison)(int,int),
+ void (CDelaunay::*swap)(int,int),
+ void (CDelaunay::*copy)(int,int))
+{
+ int m,sij,si,sj,sL,sk;
+ int stack[DM];
+
+ if (highelt-lowelt<=1) {
+ return;
+ }
+ if (highelt-lowelt>QQ) {
+ m = 0;
+ si = lowelt; sj = highelt;
+ for (;;) { // partition [si,sj] about median-of-3.
+ sij = (sj+si) >> 1;
+
+ // Now to sort elements si,sij,sj into order & set temp=their median
+ if ( (this->*comparison)( si,sij ) > 0 ) {
+ (this->*swap)( si,sij );
+ }
+ if ( (this->*comparison)( sij,sj ) > 0 ) {
+ (this->*swap)( sj,sij );
+ if ( (this->*comparison)( si,sij ) > 0 ) {
+ (this->*swap)( si,sij );
+ }
+ }
+ (this->*copy)( sij,temp );
+
+ // Now to partition into elements <=temp, >=temp, and ==temp.
+ sk = si; sL = sj;
+ do {
+ do {
+ sL--;
+ } while( (this->*comparison)( sL,temp ) > 0 );
+ do {
+ sk++;
+ } while( (this->*comparison)( temp,sk ) > 0 );
+ if ( sk < sL ) {
+ (this->*swap)( sL,sk );
+ }
+ } while(sk <= sL);
+
+ // Now to recurse on shorter partition, store longer partition on stack
+ if ( sL-si > sj-sk ) {
+ if ( sL-si < QQ ) {
+ if( m==0 ) {
+ break; // empty stack && both partitions < QQ so break
+ } else {
+ sj = stack[--m];
+ si = stack[--m];
+ }
+ }
+ else {
+ if ( sj-sk < QQ ) {
+ sj = sL;
+ } else {
+ stack[m++] = si;
+ stack[m++] = sL;
+ si = sk;
+ }
+ }
+ }
+ else {
+ if ( sj-sk < QQ ) {
+ if ( m==0 ) {
+ break; // empty stack && both partitions < QQ so break
+ } else {
+ sj = stack[--m];
+ si = stack[--m];
+ }
+ }
+ else {
+ if ( sL-si < QQ ) {
+ si = sk;
+ } else {
+ stack[m++] = sk;
+ stack[m++] = sj;
+ sj = sL;
+ }
+ }
+ }
+ }
+ }
+
+ // Now for 0 or Data bounded "straight insertion" sort of [0,nels-1]; if it is
+ // known that el[-1] = -INF, then can omit the "sk>=0" test and save time.
+ for (si=lowelt; si<highelt; si++) {
+ if ( (this->*comparison)( si,si+1 ) > 0 ) {
+ (this->*copy)( si+1,temp );
+ sj = sk = si;
+ sj++;
+ do {
+ (this->*copy)( sk,sj );
+ sj = sk;
+ sk--;
+ } while ( (this->*comparison)( sk,temp ) > 0 && sk>=lowelt );
+ (this->*copy)( temp,sj );
+ }
+ }
+}
+
+//
+// Geometric primitives
+//
+
+// incircle, as in the Guibas-Stolfi paper.
+int CDelaunay::incircle(SitePointer a, SitePointer b, SitePointer c, SitePointer d)
+{
+ double adx, ady, bdx, bdy, cdx, cdy, dx, dy, nad, nbd, ncd;
+ dx = sa[d].X();
+ dy = sa[d].Y();
+ adx = sa[a].X() - dx;
+ ady = sa[a].Y() - dy;
+ bdx = sa[b].X() - dx;
+ bdy = sa[b].Y() - dy;
+ cdx = sa[c].X() - dx;
+ cdy = sa[c].Y() - dy;
+ nad = adx*adx+ady*ady;
+ nbd = bdx*bdx+bdy*bdy;
+ ncd = cdx*cdx+cdy*cdy;
+ return( (0.0 < (nad * (bdx * cdy - bdy * cdx)
+ + nbd * (cdx * ady - cdy * adx)
+ + ncd * (adx * bdy - ady * bdx))) ? TRUE : FALSE );
+}
+
+// TRUE iff A, B, C form a counterclockwise oriented triangle
+int CDelaunay::ccw(SitePointer a, SitePointer b, SitePointer c)
+{
+ int result;
+
+ double ax = sa[a].X();
+ double bx = sa[b].X();
+ double cx = sa[c].X();
+ double ay = sa[a].Y();
+ double by = sa[b].Y();
+ double cy = sa[c].Y();
+
+ double val = (ax - cx)*(by - cy) - (bx - cx)*(ay - cy);
+ if ( val > 0.0) {
+ return true;
+ }
+
+ return false;
+}
+
+//
+// The Merge Procedure.
+//
+
+void CDelaunay::doMerge(EdgePointer *ldo, EdgePointer ldi, EdgePointer rdi, EdgePointer *rdo)
+{
+ int rvalid, lvalid;
+ EdgePointer basel,lcand,rcand,t;
+
+ for (;;) {
+ while (ccw(orig(ldi), dest(ldi), orig(rdi))) {
+ ldi = (EdgePointer) lnext(ldi);
+ }
+ if (ccw(dest(rdi), orig(rdi), orig(ldi))) {
+ rdi = (EdgePointer)rprev(rdi);
+ } else {
+ break;
+ }
+ }
+
+ basel = connectLeft((EdgePointer) sym(rdi), ldi);
+ lcand = rprev(basel);
+ rcand = (EdgePointer) oprev(basel);
+ if (orig(basel) == orig(*rdo)) {
+ *rdo = basel;
+ }
+ if (dest(basel) == orig(*ldo)) {
+ *ldo = (EdgePointer) sym(basel);
+ }
+
+ for (;;) {
+#if 1
+ if (valid(t=onext(lcand))) {
+#else
+ t = (EdgePointer)onext(lcand);
+ if (valid(basel, t)) {
+#endif
+ while (incircle(dest(lcand), dest(t), orig(lcand), orig(basel))) {
+ deleteEdge(lcand);
+ lcand = t;
+ t = onext(lcand);
+ }
+ }
+#if 1
+ if (valid(t=(EdgePointer)oprev(rcand))) {
+#else
+ t = (EdgePointer)oprev(rcand);
+ if (valid(basel, t)) {
+#endif
+ while (incircle(dest(t), dest(rcand), orig(rcand), dest(basel))) {
+ deleteEdge(rcand);
+ rcand = t;
+ t = (EdgePointer)oprev(rcand);
+ }
+ }
+
+#if 1
+ lvalid = valid(lcand);
+ rvalid = valid(rcand);
+#else
+ lvalid = valid(basel, lcand);
+ rvalid = valid(basel, rcand);
+#endif
+ if ((! lvalid) && (! rvalid)) {
+ return;
+ }
+
+ if (!lvalid ||
+ (rvalid && incircle(dest(lcand), orig(lcand), orig(rcand), dest(rcand)))) {
+ basel = connectLeft(rcand, (EdgePointer) sym(basel));
+ rcand = (EdgePointer) lnext(sym(basel));
+ } else {
+ basel = (EdgePointer) sym(connectRight(lcand, basel));
+ lcand = rprev(basel);
+ }
+ }
+}
+
+int CDelaunay::constructList(EdgePointer last, int width, int height)
+{
+ int c, i;
+ EdgePointer curr, src, nex;
+ SEdgeVector *currv, *prevv;
+
+ c = (int) ((curr = (EdgePointer) ((last & ~3))) >> 1);
+
+ for (last -= 4; last >= 0; last -= 4) {
+ src = orig(last);
+ nex = dest(last);
+ orig(--curr) = src;
+ orig(--curr) = nex;
+ orig(--curr) = nex;
+ orig(--curr) = src;
+ }
+ rcssort(0, c - 1, -1, &CDelaunay::cmpev, &CDelaunay::swapev, &CDelaunay::copyev);
+
+ // Throw out any edges that are too far apart
+ currv = prevv = ev;
+ for (i = c; i--; currv++) {
+ if ((int) fabs(sa[currv->first].getVCenter().x - sa[currv->second].getVCenter().x) <= width &&
+ (int) fabs(sa[currv->first].getVCenter().y - sa[currv->second].getVCenter().y) <= height) {
+ *(prevv++) = *currv;
+ } else {
+ c--;
+ }
+ }
+ return c;
+}
+
+// Fill in site neighbor information
+void CDelaunay::linkNeighbors(SEdgeVector *edge, int nedge, int nsite)
+{
+ int i;
+
+ for (i = 0; i < nsite; i++) {
+ sa[i].setNeighbor(edge);
+ sa[i].setNumNeighbors(0);
+ for (; edge->first == i && nedge; edge++, nedge--) {
+ sa[i].incrNumNeighbors();
+ }
+ }
+}
diff --git a/jni/feature_mos/src/mosaic/Delaunay.h b/jni/feature_mos/src/mosaic/Delaunay.h
new file mode 100644
index 0000000..7a450b5
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Delaunay.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Delaunay.h
+// $Id: Delaunay.h,v 1.9 2011/06/17 13:35:48 mbansal Exp $
+
+#ifndef DELAUNAY_H
+#define DELAUNAY_H
+#include <stdio.h>
+#include <math.h>
+#include "CSite.h"
+#include "EdgePointerUtil.h"
+
+#ifndef TRUE
+#define TRUE 1==1
+#define FALSE 0==1
+#endif
+
+//******************************************************************************
+// Reference for Quad-edge data structure:
+//
+// Leonidas Guibas and Jorge Stolfi, "Primitives for the manipulation of general
+// subdivisions and the computations of Voronoi diagrams",
+// ACM Transactions on Graphics 4, 74-123 (1985).
+//
+//******************************************************************************
+
+//
+// Common data structures
+//
+
+typedef short SitePointer;
+typedef short TrianglePointer;
+
+class CDelaunay
+{
+private:
+ CSite *sa;
+ EdgePointer oneBndryEdge;
+ EdgePointer *next;
+ SitePointer *org;
+ struct EDGE_INFO *ei;
+ SitePointer *sp;
+ SEdgeVector *ev;
+
+ SitePointer sp1;
+ EdgePointer nextEdge;
+ EdgePointer availEdge;
+
+private:
+ void build(int lo, int hi, EdgePointer *le, EdgePointer *re, int rows);
+ void buildTriangulation(int size);
+
+ EdgePointer allocEdge();
+ void freeEdge(EdgePointer e);
+
+ EdgePointer makeEdge(SitePointer origin, SitePointer destination);
+ void deleteEdge(EdgePointer e);
+
+ void splice(EdgePointer, EdgePointer);
+ EdgePointer consolidateEdges();
+ void deleteAllEdges();
+
+ void spsortx(SitePointer *, int, int);
+ void spsorty(SitePointer *, int, int);
+
+ int cmpev(int i, int j);
+ int xcmpsp(int i, int j);
+ int ycmpsp(int i, int j);
+
+ void swapsp(int i, int j);
+ void swapev(int i, int j);
+
+ void copysp(int i, int j);
+ void copyev(int i, int j);
+
+ void rcssort(int lowelt, int highelt, int temp,
+ int (CDelaunay::*comparison)(int,int),
+ void (CDelaunay::*swap)(int,int),
+ void (CDelaunay::*copy)(int,int));
+
+ void doMerge(EdgePointer *ldo, EdgePointer ldi, EdgePointer rdi, EdgePointer *rdo);
+ EdgePointer connectLeft(EdgePointer a, EdgePointer b);
+ EdgePointer connectRight(EdgePointer a, EdgePointer b);
+ int ccw(SitePointer a, SitePointer b, SitePointer c);
+ int incircle(SitePointer a, SitePointer b, SitePointer c, SitePointer d);
+ int constructList(EdgePointer e, int width, int height);
+
+public:
+ CDelaunay();
+ ~CDelaunay();
+
+ CSite *allocMemory(int nsite);
+ void freeMemory();
+ int triangulate(SEdgeVector **edge, int nsite, int width, int height);
+ void linkNeighbors(SEdgeVector *edge, int nedge, int nsite);
+};
+
+#define onext(a) next[a]
+#define oprev(a) rot(onext(rot(a)))
+#define lnext(a) rot(onext(rotinv(a)))
+#define lprev(a) sym(onext(a))
+#define rnext(a) rotinv(onext(rot(a)))
+#define rprev(a) onext(sym(a))
+#define dnext(a) sym(onext(sym(a)))
+#define dprev(a) rotinv(onext(rotinv(a)))
+
+#define orig(a) org[a]
+#define dest(a) orig(sym(a))
+#define left(a) orig(rotinv(a))
+#define right(a) orig(rot(a))
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/EdgePointerUtil.h b/jni/feature_mos/src/mosaic/EdgePointerUtil.h
new file mode 100644
index 0000000..fad05d7
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/EdgePointerUtil.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _EDGEPOINTERUTIL_H_
+#define _EDGEPOINTERUTIL_H_
+
+typedef short EdgePointer;
+
+inline EdgePointer sym(EdgePointer a)
+{
+ return a ^ 2;
+}
+
+inline EdgePointer rot(EdgePointer a)
+{
+ return (((a) + 1) & 3) | ((a) & ~3);
+}
+
+inline EdgePointer rotinv(EdgePointer a)
+{
+ return (((a) + 3) & 3) | ((a) & ~3);
+}
+
+#endif //_EDGEPOINTERUTIL_H_
diff --git a/jni/feature_mos/src/mosaic/Geometry.h b/jni/feature_mos/src/mosaic/Geometry.h
new file mode 100644
index 0000000..0efa0f4
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Geometry.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/////////////////////////////
+// Geometry.h
+// $Id: Geometry.h,v 1.2 2011/06/17 13:35:48 mbansal Exp $
+
+#pragma once
+#include "MosaicTypes.h"
+
+///////////////////////////////////////////////////////////////
+///////////////// BEG GLOBAL ROUTINES /////////////////////////
+///////////////////////////////////////////////////////////////
+
+
+inline double hypotSq(double a, double b)
+{
+ return ((a)*(a)+(b)*(b));
+}
+
+inline void ClipRect(double x, double y, BlendRect &brect)
+{
+ if (y < brect.bot) brect.bot = y;
+ if (y > brect.top) brect.top = y;
+ if (x < brect.lft) brect.lft = x;
+ if (x > brect.rgt) brect.rgt = x;
+}
+
+inline void ClipRect(BlendRect rrect, BlendRect &brect)
+{
+ if (rrect.bot < brect.bot) brect.bot = rrect.bot;
+ if (rrect.top > brect.top) brect.top = rrect.top;
+ if (rrect.lft < brect.lft) brect.lft = rrect.lft;
+ if (rrect.rgt > brect.rgt) brect.rgt = rrect.rgt;
+}
+
+// Clip x to be within [-border,width+border-1]
+inline void clipToSegment(int &x, int width, int border)
+{
+ if(x < -border)
+ x = -border;
+ else if(x >= width+border)
+ x = width + border - 1;
+}
+
+// Return true if x within [-border,width+border-1]
+inline bool inSegment(int x, int width, int border)
+{
+ return (x >= -border && x < width + border - 1);
+}
+
+inline void FindTriangleCentroid(double x0, double y0, double x1, double y1,
+ double x2, double y2,
+ double &mass, double &centX, double &centY)
+{
+ // Calculate the centroid of the triangle
+ centX = (x0 + x1 + x2) / 3.0;
+ centY = (y0 + y1 + y2) / 3.0;
+
+ // Calculate 2*Area for the triangle
+ if (y0 == y2)
+ {
+ if (x0 == x1)
+ {
+ mass = fabs((y1 - y0) * (x2 - x0)); // Special case 1a
+ }
+ else
+ {
+ mass = fabs((y1 - y0) * (x1 - x0)); // Special case 1b
+ }
+ }
+ else if (x0 == x2)
+ {
+ if (x0 == x1)
+ {
+ mass = fabs((x2 - x0) * (y2 - y0)); // Special case 2a
+ }
+ else
+ {
+ mass = fabs((x1 - x0) * (y2 - y0)); // Special case 2a
+ }
+ }
+ else if (x1 == x2)
+ {
+ mass = fabs((x1 - x0) * (y2 - y0)); // Special case 3
+ }
+ else
+ {
+ // Calculate line equation from x0,y0 to x2,y2
+ double dx = x2 - x0;
+ double dy = y2 - y0;
+ // Calculate the length of the side
+ double len1 = sqrt(dx * dx + dy * dy);
+ double m1 = dy / dx;
+ double b1 = y0 - m1 * x0;
+ // Calculate the line that goes through x1,y1 and is perpendicular to
+ // the other line
+ double m2 = 1.0 / m1;
+ double b2 = y1 - m2 * x1;
+ // Calculate the intersection of the two lines
+ if (fabs( m1 - m2 ) > 1.e-6)
+ {
+ double x = (b2 - b1) / (m1 - m2);
+ // the mass is the base * height
+ dx = x1 - x;
+ dy = y1 - m1 * x + b1;
+ mass = len1 * sqrt(dx * dx + dy * dy);
+ }
+ else
+ {
+ mass = fabs( (y1 - y0) * (x2 - x0) );
+ }
+ }
+}
+
+inline void FindQuadCentroid(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3,
+ double &centX, double &centY)
+
+{
+ // To find the centroid:
+ // 1) Divide the quadrilateral into two triangles by scribing a diagonal
+ // 2) Calculate the centroid of each triangle (the intersection of the angle bisections).
+ // 3) Find the centroid of the quad by weighting each triangle centroids by their area.
+
+ // Calculate the corner points
+ double z;
+
+ // The quad is split from x0,y0 to x2,y2
+ double mass1, mass2, cent1x, cent2x, cent1y, cent2y;
+ FindTriangleCentroid(x0, y0, x1, y1, x2, y2, mass1, cent1x, cent1y);
+ FindTriangleCentroid(x0, y0, x3, y3, x2, y2, mass2, cent2x, cent2y);
+
+ // determine position of quad centroid
+ z = mass2 / (mass1 + mass2);
+ centX = cent1x + (cent2x - cent1x) * z;
+ centY = cent1y + (cent2y - cent1y) * z;
+}
+
+///////////////////////////////////////////////////////////////
+////////////////// END GLOBAL ROUTINES ////////////////////////
+///////////////////////////////////////////////////////////////
+
+
diff --git a/jni/feature_mos/src/mosaic/ImageUtils.cpp b/jni/feature_mos/src/mosaic/ImageUtils.cpp
new file mode 100644
index 0000000..792b90d
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/ImageUtils.cpp
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// ImageUtils.cpp
+// $Id: ImageUtils.cpp,v 1.12 2011/06/17 13:35:48 mbansal Exp $
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#include "ImageUtils.h"
+
+void ImageUtils::rgb2yvu(ImageType out, ImageType in, int width, int height)
+{
+ int r,g,b;
+ ImageType yimg = out;
+ ImageType vimg = yimg + width*height;
+ ImageType uimg = vimg + width*height;
+ ImageType image = in;
+
+ for (int ii = 0; ii < height; ii++) {
+ for (int ij = 0; ij < width; ij++) {
+ r = (*image++);
+ g = (*image++);
+ b = (*image++);
+
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+ int val = (int) (REDY * r + GREENY * g + BLUEY * b) / 1000 + 16;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ *(yimg) = val;
+
+ val = (int) (REDV * r - GREENV * g - BLUEV * b) / 1000 + 128;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ *(vimg) = val;
+
+ val = (int) (-REDU * r - GREENU * g + BLUEU * b) / 1000 + 128;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ *(uimg) = val;
+
+ yimg++;
+ uimg++;
+ vimg++;
+ }
+ }
+}
+
+ImageType ImageUtils::rgb2gray(ImageType in, int width, int height)
+{
+ int r,g,b, nr, ng, nb, val;
+ ImageType gray = NULL;
+ ImageType image = in;
+ ImageType out = ImageUtils::allocateImage(width, height, 1);
+ ImageType outCopy = out;
+
+ for (int ii = 0; ii < height; ii++) {
+ for (int ij = 0; ij < width; ij++) {
+ r = (*image++);
+ g = (*image++);
+ b = (*image++);
+
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+ (*outCopy) = ( 0.3*r + 0.59*g + 0.11*b);
+
+ outCopy++;
+ }
+ }
+
+ return out;
+}
+
+ImageType ImageUtils::rgb2gray(ImageType out, ImageType in, int width, int height)
+{
+ int r,g,b, nr, ng, nb, val;
+ ImageType gray = out;
+ ImageType image = in;
+ ImageType outCopy = out;
+
+ for (int ii = 0; ii < height; ii++) {
+ for (int ij = 0; ij < width; ij++) {
+ r = (*image++);
+ g = (*image++);
+ b = (*image++);
+
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+ (*outCopy) = ( 0.3*r + 0.59*g + 0.11*b);
+
+ outCopy++;
+ }
+ }
+
+ return out;
+
+}
+
+ImageType *ImageUtils::imageTypeToRowPointers(ImageType in, int width, int height)
+{
+ int i;
+ int m_h = height;
+ int m_w = width;
+
+ ImageType *m_rows = new ImageType[m_h];
+
+ for (i=0;i<m_h;i++) {
+ m_rows[i] = &in[(m_w)*i];
+ }
+ return m_rows;
+}
+
+void ImageUtils::yvu2rgb(ImageType out, ImageType in, int width, int height)
+{
+ int y,v,u, r, g, b;
+ unsigned char *yimg = in;
+ unsigned char *vimg = yimg + width*height;
+ unsigned char *uimg = vimg + width*height;
+ unsigned char *image = out;
+
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+
+ y = (*yimg);
+ v = (*vimg);
+ u = (*uimg);
+
+ if (y < 0) y = 0;
+ if (y > 255) y = 255;
+ if (u < 0) u = 0;
+ if (u > 255) u = 255;
+ if (v < 0) v = 0;
+ if (v > 255) v = 255;
+
+ b = (int) ( 1.164*(y - 16) + 2.018*(u-128));
+ g = (int) ( 1.164*(y - 16) - 0.813*(v-128) - 0.391*(u-128));
+ r = (int) ( 1.164*(y - 16) + 1.596*(v-128));
+
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+ *(image++) = r;
+ *(image++) = g;
+ *(image++) = b;
+
+ yimg++;
+ uimg++;
+ vimg++;
+
+ }
+ }
+}
+
+void ImageUtils::yvu2bgr(ImageType out, ImageType in, int width, int height)
+{
+ int y,v,u, r, g, b;
+ unsigned char *yimg = in;
+ unsigned char *vimg = yimg + width*height;
+ unsigned char *uimg = vimg + width*height;
+ unsigned char *image = out;
+
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+
+ y = (*yimg);
+ v = (*vimg);
+ u = (*uimg);
+
+ if (y < 0) y = 0;
+ if (y > 255) y = 255;
+ if (u < 0) u = 0;
+ if (u > 255) u = 255;
+ if (v < 0) v = 0;
+ if (v > 255) v = 255;
+
+ b = (int) ( 1.164*(y - 16) + 2.018*(u-128));
+ g = (int) ( 1.164*(y - 16) - 0.813*(v-128) - 0.391*(u-128));
+ r = (int) ( 1.164*(y - 16) + 1.596*(v-128));
+
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+ *(image++) = b;
+ *(image++) = g;
+ *(image++) = r;
+
+ yimg++;
+ uimg++;
+ vimg++;
+
+ }
+ }
+}
+
+
+ImageType ImageUtils::readBinaryPPM(const char *filename, int &width, int &height)
+{
+
+ FILE *imgin = NULL;
+ int mval=0, format=0, eret;
+ ImageType ret = IMAGE_TYPE_NOIMAGE;
+
+ imgin = fopen(filename, "r");
+ if (imgin == NULL) {
+ fprintf(stderr, "Error: Filename %s not found\n", filename);
+ return ret;
+ }
+
+ eret = fscanf(imgin, "P%d\n", &format);
+ if (format != 6) {
+ fprintf(stderr, "Error: readBinaryPPM only supports PPM format (P6)\n");
+ return ret;
+ }
+
+ eret = fscanf(imgin, "%d %d\n", &width, &height);
+ eret = fscanf(imgin, "%d\n", &mval);
+ ret = allocateImage(width, height, IMAGE_TYPE_NUM_CHANNELS);
+ eret = fread(ret, sizeof(ImageTypeBase), IMAGE_TYPE_NUM_CHANNELS*width*height, imgin);
+
+ fclose(imgin);
+
+ return ret;
+
+}
+
+void ImageUtils::writeBinaryPPM(ImageType image, const char *filename, int width, int height, int numChannels)
+{
+ FILE *imgout = fopen(filename, "w");
+
+ if (imgout == NULL) {
+ fprintf(stderr, "Error: Filename %s could not be opened for writing\n", filename);
+ return;
+ }
+
+ if (numChannels == 3) {
+ fprintf(imgout, "P6\n%d %d\n255\n", width, height);
+ } else if (numChannels == 1) {
+ fprintf(imgout, "P5\n%d %d\n255\n", width, height);
+ } else {
+ fprintf(stderr, "Error: writeBinaryPPM: Unsupported number of channels\n");
+ }
+ fwrite(image, sizeof(ImageTypeBase), numChannels*width*height, imgout);
+
+ fclose(imgout);
+
+}
+
+ImageType ImageUtils::allocateImage(int width, int height, int numChannels, short int border)
+{
+ int overallocation = 256;
+ return (ImageType) calloc(width*height*numChannels+overallocation, sizeof(ImageTypeBase));
+}
+
+
+void ImageUtils::freeImage(ImageType image)
+{
+ free(image);
+}
+
+
+// allocation of one color image used for tmp buffers, etc.
+// format of contiguous memory block:
+// YUVInfo struct (type + BimageInfo for Y,U, and V),
+// Y row pointers
+// U row pointers
+// V row pointers
+// Y image pixels
+// U image pixels
+// V image pixels
+YUVinfo *YUVinfo::allocateImage(unsigned short width, unsigned short height)
+{
+ unsigned short heightUV, widthUV;
+
+ widthUV = width;
+ heightUV = height;
+
+ // figure out how much space to hold all pixels...
+ int size = (((width * height * 32) >> 3) + 8);
+ unsigned char *position = 0;
+
+ // VC 8 does not like calling free on yuv->Y.ptr since it is in
+ // the middle of a block. So rearrange the memory layout so after
+ // calling mapYUVInforToImage yuv->Y.ptr points to the begginning
+ // of the calloc'ed block.
+ YUVinfo *yuv = (YUVinfo *) calloc(sizeof(YUVinfo), 1);
+ if (yuv) {
+ yuv->Y.width = yuv->Y.pitch = width;
+ yuv->Y.height = height;
+ yuv->Y.border = yuv->U.border = yuv->V.border = (unsigned short) 0;
+ yuv->U.width = yuv->U.pitch = yuv->V.width = yuv->V.pitch = widthUV;
+ yuv->U.height = yuv->V.height = heightUV;
+
+ unsigned char* block = (unsigned char*) calloc(
+ sizeof(unsigned char *) * (height + heightUV + heightUV) +
+ sizeof(unsigned char) * size, 1);
+
+ position = block;
+ unsigned char **y = (unsigned char **) (block + size);
+
+ /* Initialize and assign row pointers */
+ yuv->Y.ptr = y;
+ yuv->V.ptr = &y[height];
+ yuv->U.ptr = &y[height + heightUV];
+ }
+ if (size)
+ mapYUVInfoToImage(yuv, position);
+ return yuv;
+}
+
+// wrap YUVInfo row pointers around 3 contiguous image (color component) planes.
+// position = starting pixel in image.
+void YUVinfo::mapYUVInfoToImage(YUVinfo *img, unsigned char *position)
+{
+ int i;
+ for (i = 0; i < img->Y.height; i++, position += img->Y.width)
+ img->Y.ptr[i] = position;
+ for (i = 0; i < img->V.height; i++, position += img->V.width)
+ img->V.ptr[i] = position;
+ for (i = 0; i < img->U.height; i++, position += img->U.width)
+ img->U.ptr[i] = position;
+}
+
+
diff --git a/jni/feature_mos/src/mosaic/ImageUtils.h b/jni/feature_mos/src/mosaic/ImageUtils.h
new file mode 100644
index 0000000..9a47cc1
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/ImageUtils.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// ImageUtils.h
+// $Id: ImageUtils.h,v 1.9 2011/05/16 15:33:06 mbansal Exp $
+
+#ifndef IMAGE_UTILS_H
+#define IMAGE_UTILS_H
+
+#include <stdlib.h>
+
+/**
+ * Definition of basic image types
+ */
+typedef unsigned char ImageTypeBase;
+typedef ImageTypeBase *ImageType;
+
+typedef short ImageTypeShortBase;
+typedef ImageTypeShortBase *ImageTypeShort;
+
+typedef float ImageTypeFloatBase;
+typedef ImageTypeFloatBase *ImageTypeFloat;
+
+
+class ImageUtils {
+public:
+
+ /**
+ * Default number of channels in image.
+ */
+ static const int IMAGE_TYPE_NUM_CHANNELS = 3;
+
+ /**
+ * Definition of an empty image.
+ */
+ static const int IMAGE_TYPE_NOIMAGE = NULL;
+
+ /**
+ * Convert image from BGR (interlaced) to YVU (non-interlaced)
+ *
+ * Arguments:
+ * out: Resulting image (note must be preallocated before
+ * call)
+ * in: Input image
+ * width: Width of input image
+ * height: Height of input image
+ */
+ static void rgb2yvu(ImageType out, ImageType in, int width, int height);
+
+ /**
+ * Convert image from YVU (non-interlaced) to BGR (interlaced)
+ *
+ * Arguments:
+ * out: Resulting image (note must be preallocated before
+ * call)
+ * in: Input image
+ * width: Width of input image
+ * height: Height of input image
+ */
+ static void yvu2rgb(ImageType out, ImageType in, int width, int height);
+ static void yvu2bgr(ImageType out, ImageType in, int width, int height);
+
+ /**
+ * Convert image from BGR to grayscale
+ *
+ * Arguments:
+ * in: Input image
+ * width: Width of input image
+ * height: Height of input image
+ *
+ * Return:
+ * Pointer to resulting image (allocation is done here, free
+ * must be done by caller)
+ */
+ static ImageType rgb2gray(ImageType in, int width, int height);
+ static ImageType rgb2gray(ImageType out, ImageType in, int width, int height);
+
+ /**
+ * Read a binary PPM image
+ */
+ static ImageType readBinaryPPM(const char *filename, int &width, int &height);
+
+ /**
+ * Write a binary PPM image
+ */
+ static void writeBinaryPPM(ImageType image, const char *filename, int width, int height, int numChannels = IMAGE_TYPE_NUM_CHANNELS);
+
+ /**
+ * Allocate space for a standard image.
+ */
+ static ImageType allocateImage(int width, int height, int numChannels, short int border = 0);
+
+ /**
+ * Free memory of image
+ */
+ static void freeImage(ImageType image);
+
+ static ImageType *imageTypeToRowPointers(ImageType out, int width, int height);
+ /**
+ * Get time.
+ */
+ static double getTime();
+
+protected:
+
+ /**
+ * Constants for YVU/RGB conversion
+ */
+ static const int REDY = 257;
+ static const int REDV = 439;
+ static const int REDU = 148;
+ static const int GREENY = 504;
+ static const int GREENV = 368;
+ static const int GREENU = 291;
+ static const int BLUEY = 98;
+ static const int BLUEV = 71;
+ static const int BLUEU = 439;
+
+};
+
+/**
+ * Structure containing an image and other bookkeeping items.
+ * Used in YUVinfo to store separate YVU image planes.
+ */
+typedef struct {
+ ImageType *ptr;
+ unsigned short width;
+ unsigned short height;
+ unsigned short border;
+ unsigned short pitch;
+} BimageInfo;
+
+/**
+ * A YUV image container,
+ */
+class YUVinfo {
+public:
+ static YUVinfo *allocateImage(unsigned short width, unsigned short height);
+ static void mapYUVInfoToImage(YUVinfo *img, unsigned char *position);
+
+ /**
+ * Y Plane
+ */
+ BimageInfo Y;
+
+ /**
+ * V (1st color) plane
+ */
+ BimageInfo V;
+
+ /**
+ * U (1st color) plane
+ */
+ BimageInfo U;
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/Interp.h b/jni/feature_mos/src/mosaic/Interp.h
new file mode 100644
index 0000000..19c4a40
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Interp.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////
+// Interp.h
+// $Id: Interp.h,v 1.2 2011/06/17 13:35:48 mbansal Exp $
+
+#ifndef INTERP_H
+#define INTERP_H
+
+#include "Pyramid.h"
+
+#define CTAPS 40
+static double ciTable[81] = {
+ 1, 0.998461, 0.993938, 0.98657, 0.9765,
+ 0.963867, 0.948813, 0.931477, 0.912, 0.890523,
+ 0.867188, 0.842133, 0.8155, 0.78743, 0.758062,
+ 0.727539, 0.696, 0.663586, 0.630437, 0.596695,
+ 0.5625, 0.527992, 0.493312, 0.458602, 0.424,
+ 0.389648, 0.355687, 0.322258, 0.2895, 0.257555,
+ 0.226562, 0.196664, 0.168, 0.140711, 0.114937,
+ 0.0908203, 0.0685, 0.0481172, 0.0298125, 0.0137266,
+ 0, -0.0118828, -0.0225625, -0.0320859, -0.0405,
+ -0.0478516, -0.0541875, -0.0595547, -0.064, -0.0675703,
+ -0.0703125, -0.0722734, -0.0735, -0.0740391, -0.0739375,
+ -0.0732422, -0.072, -0.0702578, -0.0680625, -0.0654609,
+ -0.0625, -0.0592266, -0.0556875, -0.0519297, -0.048,
+ -0.0439453, -0.0398125, -0.0356484, -0.0315, -0.0274141,
+ -0.0234375, -0.0196172, -0.016, -0.0126328, -0.0095625,
+ -0.00683594, -0.0045, -0.00260156, -0.0011875, -0.000304687, 0.0
+};
+
+inline double ciCalc(PyramidShort *img, int xi, int yi, double xfrac, double yfrac)
+{
+ double tmpf[4];
+
+ // Interpolate using 16 points
+ ImageTypeShortBase *in = img->ptr[yi-1] + xi - 1;
+ int off = (int)(xfrac * CTAPS);
+
+ tmpf[0] = in[0] * ciTable[off + 40];
+ tmpf[0] += in[1] * ciTable[off];
+ tmpf[0] += in[2] * ciTable[40 - off];
+ tmpf[0] += in[3] * ciTable[80 - off];
+ in += img->pitch;
+ tmpf[1] = in[0] * ciTable[off + 40];
+ tmpf[1] += in[1] * ciTable[off];
+ tmpf[1] += in[2] * ciTable[40 - off];
+ tmpf[1] += in[3] * ciTable[80 - off];
+ in += img->pitch;
+ tmpf[2] = in[0] * ciTable[off + 40];
+ tmpf[2] += in[1] * ciTable[off];
+ tmpf[2] += in[2] * ciTable[40 - off];
+ tmpf[2] += in[3] * ciTable[80 - off];
+ in += img->pitch;
+ tmpf[3] = in[0] * ciTable[off + 40];
+ tmpf[3] += in[1] * ciTable[off];
+ tmpf[3] += in[2] * ciTable[40 - off];
+ tmpf[3] += in[3] * ciTable[80 - off];
+
+ // this is the final interpolation
+ off = (int)(yfrac * CTAPS);
+ return (ciTable[off + 40] * tmpf[0] + ciTable[off] * tmpf[1] +
+ ciTable[40 - off] * tmpf[2] + ciTable[80 - off] * tmpf[3]);
+}
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/MatrixUtils.h b/jni/feature_mos/src/mosaic/MatrixUtils.h
new file mode 100644
index 0000000..a0b84d8
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/MatrixUtils.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Matrixutils.h
+// $Id: MatrixUtils.h,v 1.5 2011/05/16 15:33:06 mbansal Exp $
+
+
+#ifndef MATRIX_UTILS_H
+#define MATRIX_UTILS_H
+
+/* Simple class for 3x3 matrix, mainly used to convert from 9x1
+ * to 3x3
+ */
+class Matrix33 {
+public:
+
+ /**
+ * Empty constructor
+ */
+ Matrix33() {
+ initialize();
+ }
+
+ /**
+ * Constructor with identity initialization
+ * Arguments:
+ * identity: Specifies wether to initialize matrix to
+ * identity or zeros
+ */
+ Matrix33(bool identity) {
+ initialize(identity);
+ }
+
+ /**
+ * Initialize to identity matrix
+ */
+ void initialize(bool identity = false) {
+ mat[0][1] = mat[0][2] = mat[1][0] = mat[1][2] = mat[2][0] = mat[2][1] = 0.0;
+ if (identity) {
+ mat[0][0] = mat[1][1] = mat[2][2] = 1.0;
+ } else {
+ mat[0][0] = mat[1][1] = mat[2][2] = 0.0;
+ }
+ }
+
+ /**
+ * Conver ta 9x1 matrix to a 3x3 matrix
+ */
+ static void convert9to33(double out[3][3], double in[9]) {
+ out[0][0] = in[0];
+ out[0][1] = in[1];
+ out[0][2] = in[2];
+
+ out[1][0] = in[3];
+ out[1][1] = in[4];
+ out[1][2] = in[5];
+
+ out[2][0] = in[6];
+ out[2][1] = in[7];
+ out[2][2] = in[8];
+
+ }
+
+ /* Matrix data */
+ double mat[3][3];
+
+};
+
+/* Simple class for 9x1 matrix, mainly used to convert from 3x3
+ * to 9x1
+ */
+class Matrix9 {
+public:
+
+ /**
+ * Empty constructor
+ */
+ Matrix9() {
+ initialize();
+ }
+
+ /**
+ * Constructor with identity initialization
+ * Arguments:
+ * identity: Specifies wether to initialize matrix to
+ * identity or zeros
+ */
+ Matrix9(bool identity) {
+ initialize(identity);
+ }
+
+ /**
+ * Initialize to identity matrix
+ */
+ void initialize(bool identity = false) {
+ mat[1] = mat[2] = mat[3] = mat[5] = mat[6] = mat[7] = 0.0;
+ if (identity) {
+ mat[0] = mat[4] = mat[8] = 1.0;
+ } else {
+ mat[0] = mat[4] = mat[8] = 0.0;
+ }
+ }
+
+ /**
+ * Conver ta 3x3 matrix to a 9x1 matrix
+ */
+ static void convert33to9(double out[9], double in[3][3]) {
+ out[0] = in[0][0];
+ out[1] = in[0][1];
+ out[2] = in[0][2];
+
+ out[3] = in[1][0];
+ out[4] = in[1][1];
+ out[5] = in[1][2];
+
+ out[6] = in[2][0];
+ out[7] = in[2][1];
+ out[8] = in[2][2];
+
+ }
+
+ /* Matrix data */
+ double mat[9];
+
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/Mosaic.cpp b/jni/feature_mos/src/mosaic/Mosaic.cpp
new file mode 100644
index 0000000..f8f3265
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Mosaic.cpp
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Mosaic.pp
+// S.O. # :
+// Author(s): zkira
+// $Id: Mosaic.cpp,v 1.20 2011/06/24 04:22:14 mbansal Exp $
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Mosaic.h"
+#include "trsMatrix.h"
+
+Mosaic::Mosaic()
+{
+ initialized = false;
+ imageMosaicYVU = NULL;
+ frames_size = 0;
+ max_frames = 200;
+}
+
+Mosaic::~Mosaic()
+{
+ for (int i = 0; i < frames_size; i++)
+ {
+ if (frames[i])
+ delete frames[i];
+ }
+ delete frames;
+
+ if (aligner != NULL)
+ delete aligner;
+ if (blender != NULL)
+ delete blender;
+}
+
+int Mosaic::initialize(int blendingType, int width, int height, int nframes, bool quarter_res, float thresh_still)
+{
+ this->blendingType = blendingType;
+ this->width = width;
+ this->height = height;
+
+ mosaicWidth = mosaicHeight = 0;
+ imageMosaicYVU = NULL;
+
+ frames = new MosaicFrame *[max_frames];
+
+ if(nframes>-1)
+ {
+ for(int i=0; i<nframes; i++)
+ {
+ frames[i] = new MosaicFrame(this->width,this->height,false); // Do no allocate memory for YUV data
+ }
+ }
+ else
+ {
+ for(int i=0; i<max_frames; i++)
+ {
+ frames[i] = NULL;
+ }
+
+
+ }
+
+ LOGIE("Initialize %d %d\n", width, height);
+ LOGIE("Frame width %d,%d\n", width, height);
+ LOGIE("Max num frames %d\n", max_frames);
+
+ aligner = new Align();
+ aligner->initialize(width, height,quarter_res,thresh_still);
+
+ if (blendingType == Blend::BLEND_TYPE_FULL ||
+ blendingType == Blend::BLEND_TYPE_PAN ||
+ blendingType == Blend::BLEND_TYPE_CYLPAN ||
+ blendingType == Blend::BLEND_TYPE_HORZ) {
+ blender = new Blend();
+ blender->initialize(blendingType, width, height);
+ } else {
+ blender = NULL;
+ LOGIE("Error: Unknown blending type %d\n",blendingType);
+ return MOSAIC_RET_ERROR;
+ }
+
+ initialized = true;
+
+ return MOSAIC_RET_OK;
+}
+
+int Mosaic::addFrameRGB(ImageType imageRGB)
+{
+ ImageType imageYVU;
+ // Convert to YVU24 which is used by blending
+ imageYVU = ImageUtils::allocateImage(this->width, this->height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
+ ImageUtils::rgb2yvu(imageYVU, imageRGB, width, height);
+
+ return addFrame(imageYVU);
+}
+
+int Mosaic::addFrame(ImageType imageYVU)
+{
+ if(frames[frames_size]==NULL)
+ frames[frames_size] = new MosaicFrame(this->width,this->height,false);
+
+ MosaicFrame *frame = frames[frames_size];
+
+ frame->image = imageYVU;
+
+ int align_flag = Align::ALIGN_RET_OK;
+
+ // Add frame to aligner
+ if (aligner != NULL)
+ {
+ // Note aligner takes in RGB images
+ printf("Adding frame to aligner...\n");
+ align_flag = aligner->addFrame(frame->image);
+ aligner->getLastTRS(frame->trs);
+
+ printf("Frame width %d,%d\n", frame->width, frame->height);
+ if (frames_size >= max_frames)
+ {
+ fprintf(stderr, "WARNING: More frames than preallocated, ignoring. Increase maximum number of frames (-f <max_frames>) to avoid this\n");
+ return MOSAIC_RET_ERROR;
+ }
+ else if(align_flag == Align::ALIGN_RET_OK)
+ {
+ frames_size++;
+ return MOSAIC_RET_OK;
+ }
+ else
+ {
+ return MOSAIC_RET_ERROR;
+ }
+ }
+ else
+ {
+ return MOSAIC_RET_ERROR;
+ }
+}
+
+
+int Mosaic::createMosaic()
+{
+ printf("Creating mosaic\n");
+
+ if (blendingType == Blend::BLEND_TYPE_PAN)
+ {
+
+ balanceRotations();
+
+ }
+
+ // Blend the mosaic (alignment has already been done)
+ if (blender != NULL)
+ {
+ blender->runBlend((MosaicFrame **) frames, frames_size, imageMosaicYVU, mosaicWidth, mosaicHeight);
+ }
+
+ return MOSAIC_RET_OK;
+}
+
+ImageType Mosaic::getMosaic(int &width, int &height)
+{
+ width = mosaicWidth;
+ height = mosaicHeight;
+
+ return imageMosaicYVU;
+}
+
+
+
+int Mosaic::balanceRotations()
+{
+ // Normalize to the mean angle of rotation (Smiley face)
+ double sineAngle = 0.0;
+
+ for (int i = 0; i < frames_size; i++) sineAngle += frames[i]->trs[0][1];
+ sineAngle /= frames_size;
+ // Calculate the cosineAngle (1 - sineAngle*sineAngle) = cosineAngle*cosineAngle
+ double cosineAngle = sqrt(1.0 - sineAngle*sineAngle);
+ double m[3][3] = {
+ { cosineAngle, -sineAngle, 0 },
+ { sineAngle, cosineAngle, 0},
+ { 0, 0, 1}};
+ double tmp[3][3];
+
+ for (int i = 0; i < frames_size; i++) {
+ memcpy(tmp, frames[i]->trs, sizeof(tmp));
+ mult33d(frames[i]->trs, m, tmp);
+ }
+
+ return MOSAIC_RET_OK;
+}
diff --git a/jni/feature_mos/src/mosaic/Mosaic.h b/jni/feature_mos/src/mosaic/Mosaic.h
new file mode 100644
index 0000000..c34688c
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Mosaic.h
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// Mosaic.h
+// S.O. # :
+// Author(s): zkira
+// $Id: Mosaic.h,v 1.16 2011/06/24 04:22:14 mbansal Exp $
+
+#ifndef MOSAIC_H
+#define MOSAIC_H
+
+#include "ImageUtils.h"
+#include "AlignFeatures.h"
+#include "Blend.h"
+#include "MosaicTypes.h"
+
+/*! \mainpage Mosaic
+
+ \section intro Introduction
+ The class Mosaic provides a simple interface to the panoramic mosaicing algorithm. The class allows passing in individual image frames to be stitched together, computes the alignment transformation between them, and then stitches and blends them together into a single panoramic output which can then be accessed as a single image. \
+
+ \section usage Usage
+ The class methods need to be called as outlined in the sample application which is created from the mosaic_main.cpp file in the directory src/mosaic/. A brief snapshot of the flow is given below:
+
+ \code
+ Mosaic mosaic;
+ // Define blending types to use, and the frame dimensions
+ int blendingType = Blend::BLEND_TYPE_CYLPAN;
+ int width = 640;
+ int height = 480;
+
+ while (<image frames are available>)
+ {
+ // Check for initialization and if not, initialize
+ if (!mosaic.isInitialized())
+ {
+ // Initialize mosaic processing
+ mosaic.initialize(blendingType, width, height, -1, false, 5.0f);
+ }
+
+ // Add to list of frames
+ mosaic.addFrameRGB(imageRGB);
+
+ // Free image
+ ImageUtils::freeImage(imageRGB);
+ }
+
+ // Create the mosaic
+ ret = mosaic.createMosaic();
+
+ // Get back the result
+ resultYVU = mosaic.getMosaic(mosaicWidth, mosaicHeight);
+
+ printf("Got mosaic of size %d,%d\n", mosaicWidth, mosaicHeight);
+
+ \endcode
+*/
+
+/*!
+ * Main class that creates a mosaic by creating an aligner and blender.
+ */
+class Mosaic
+{
+
+public:
+
+ Mosaic();
+ ~Mosaic();
+
+ /*!
+ * Creates the aligner and blender and initializes state.
+ * \param blendingType Type of blending to perform
+ * \param width Width of input images (note: all images must be same size)
+ * \param height Height of input images (note: all images must be same size)
+ * \param nframes Number of frames to pre-allocate; default value -1 will allocate each frame as it comes
+ * \param quarter_res Whether to compute alignment at quarter the input resolution (default = false)
+ * \param thresh_still Minimum number of pixels of translation detected between the new frame and the last frame before this frame is added to be mosaiced. For the low-res processing at 320x180 resolution input, we set this to 5 pixels. To reject no frames, set this to 0.0 (default value).
+ * \return Return code signifying success or failure.
+ */
+ int initialize(int blendingType, int width, int height, int nframes = -1, bool quarter_res = false, float thresh_still = 0.0);
+
+ /*!
+ * Adds a YVU frame to the mosaic.
+ * \param imageYVU Pointer to a YVU image.
+ * \return Return code signifying success or failure.
+ */
+ int addFrame(ImageType imageYVU);
+
+ /*!
+ * Adds a RGB frame to the mosaic.
+ * \param imageRGB Pointer to a RGB image.
+ * \return Return code signifying success or failure.
+ */
+ int addFrameRGB(ImageType imageRGB);
+
+ /*!
+ * After adding all frames, call this function to perform the final blending.
+ * \return Return code signifying success or failure.
+ */
+ int createMosaic();
+
+ /*!
+ * Obtains the resulting mosaic and its dimensions.
+ * \param width Width of the resulting mosaic (returned)
+ * \param height Height of the resulting mosaic (returned)
+ * \return Pointer to image.
+ */
+ ImageType getMosaic(int &width, int &height);
+
+ /*!
+ * Provides access to the internal alignment object pointer.
+ * \return Pointer to the aligner object.
+ */
+ Align* getAligner() { return aligner; }
+
+ /*!
+ * Obtain initialization state.
+ *
+ * return Returns true if initialized, false otherwise.
+ */
+ bool isInitialized() { return initialized; }
+
+
+ /*!
+ * Return codes for mosaic.
+ */
+ static const int MOSAIC_RET_OK = 1;
+ static const int MOSAIC_RET_ERROR = -1;
+
+protected:
+
+ /**
+ * Size of image frames making up mosaic
+ */
+ int width, height;
+
+ /**
+ * Size of actual mosaic
+ */
+ int mosaicWidth, mosaicHeight;
+
+ /**
+ * Bounding box to crop the mosaic when the gray border is not desired.
+ */
+ MosaicRect mosaicCroppingRect;
+
+ ImageType imageMosaicYVU;
+
+ /**
+ * Collection of frames that will make up mosaic.
+ */
+ MosaicFrame **frames;
+ int frames_size;
+ int max_frames;
+
+ /**
+ * Initialization state.
+ */
+ bool initialized;
+
+ /**
+ * Type of blending to perform.
+ */
+ int blendingType;
+
+ /**
+ * Pointer to aligner.
+ */
+ Align *aligner;
+
+ /**
+ * Pointer to blender.
+ */
+ Blend *blender;
+
+ /**
+ * Modifies TRS matrices so that rotations are balanced
+ * about center of mosaic
+ *
+ * Side effect: TRS matrices of all mosaic frames
+ * are modified
+ */
+ int balanceRotations();
+
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/MosaicTypes.h b/jni/feature_mos/src/mosaic/MosaicTypes.h
new file mode 100644
index 0000000..242335b
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/MosaicTypes.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// MosaicTypes.h
+// S.O. # :
+// Author(s): zkira
+// $Id: MosaicTypes.h,v 1.15 2011/06/17 13:35:48 mbansal Exp $
+
+
+#ifndef MOSAIC_TYPES_H
+#define MOSAIC_TYPES_H
+
+#include "ImageUtils.h"
+
+/**
+ * Definition of rectangle in a mosaic.
+ */
+class MosaicRect
+{
+ public:
+ MosaicRect()
+ {
+ left = right = top = bottom = 0.0;
+ }
+
+ inline int Width()
+ {
+ return right - left;
+ }
+
+ inline int Height()
+ {
+ return bottom - top;
+ }
+
+ /**
+ * Bounds of the rectangle
+ */
+ int left, right, top, bottom;
+};
+
+class BlendRect
+{
+ public:
+ double lft, rgt, top, bot;
+};
+
+/**
+ * A frame making up the mosaic.
+ * Note: Currently assumes a YVU image
+ * containing separate Y,V, and U planes
+ * in contiguous memory (in that order).
+ */
+class MosaicFrame {
+public:
+ ImageType image;
+ double trs[3][3];
+ int width, height;
+ BlendRect brect; // This frame warped to the Mosaic coordinate system
+ BlendRect vcrect; // brect clipped using the voronoi neighbors
+ bool internal_allocation;
+
+ MosaicFrame() { };
+ MosaicFrame(int _width, int _height, bool allocate=true)
+ {
+ width = _width;
+ height = _height;
+ internal_allocation = allocate;
+ if(internal_allocation)
+ image = ImageUtils::allocateImage(width, height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
+ }
+
+
+ ~MosaicFrame()
+ {
+ if(internal_allocation)
+ if (image)
+ free(image);
+ }
+
+ /**
+ * Get the V plane of the image.
+ */
+ inline ImageType getV()
+ {
+ return (image + (width*height));
+ }
+
+ /**
+ * Get the U plane of the image.
+ */
+ inline ImageType getU()
+ {
+ return (image + (width*height*2));
+ }
+
+ /**
+ * Get a pixel from the V plane of the image.
+ */
+ inline int getV(int y, int x)
+ {
+ ImageType U = image + (width*height);
+ return U[y*width+x];
+ }
+
+ /**
+ * Get a pixel from the U plane of the image.
+ */
+ inline int getU(int y, int x)
+ {
+ ImageType U = image + (width*height*2);
+ return U[y*width+x];
+ }
+
+};
+
+/**
+ * Structure for describing a warp.
+ */
+typedef struct {
+ int horizontal;
+ double theta;
+ double x;
+ double y;
+ double width;
+ double radius;
+ double direction;
+ double correction;
+ int blendRange;
+ int blendRangeUV;
+ int nlevs;
+ int nlevsC;
+ int blendingType;
+ // Add an overlap to prevent a gap between pictures due to roundoffs
+ double roundoffOverlap;// 1.5
+
+} BlendParams;
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/Pyramid.cpp b/jni/feature_mos/src/mosaic/Pyramid.cpp
new file mode 100644
index 0000000..945eafb
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Pyramid.cpp
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// pyramid.cpp
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Pyramid.h"
+
+// We allocate the entire pyramid into one contiguous storage. This makes
+// cleanup easier than fragmented stuff. In addition, we added a "pitch"
+// field, so pointer manipulation is much simpler when it would be faster.
+PyramidShort *PyramidShort::allocatePyramidPacked(real levels,
+ real width, real height, real border)
+{
+ real border2 = (real) (border << 1);
+ int lines, size = calcStorage(width, height, border2, levels, &lines);
+
+ PyramidShort *img = (PyramidShort *) calloc(sizeof(PyramidShort) * levels
+ + sizeof(short *) * lines +
+ + sizeof(short) * size, 1);
+
+ if (img) {
+ PyramidShort *curr, *last;
+ ImageTypeShort *y = (ImageTypeShort *) &img[levels];
+ ImageTypeShort position = (ImageTypeShort) &y[lines];
+ for (last = (curr = img) + levels; curr < last; curr++) {
+ curr->width = width;
+ curr->height = height;
+ curr->border = border;
+ curr->pitch = (real) (width + border2);
+ curr->ptr = y + border;
+
+ // Assign row pointers
+ for (int j = height + border2; j--; y++, position += curr->pitch) {
+ *y = position + border;
+ }
+
+ width >>= 1;
+ height >>= 1;
+ }
+ }
+
+ return img;
+}
+
+// Allocate an image of type short
+PyramidShort *PyramidShort::allocateImage(real width, real height, real border)
+{
+ real border2 = (real) (border << 1);
+ PyramidShort *img = (PyramidShort *)
+ calloc(sizeof(PyramidShort) + sizeof(short *) * (height + border2) +
+ sizeof(short) * (width + border2) * (height + border2), 1);
+
+ if (img) {
+ short **y = (short **) &img[1];
+ short *position = (short *) &y[height + border2];
+ img->width = width;
+ img->height = height;
+ img->border = border;
+ img->pitch = (real) (width + border2);
+ img->ptr = y + border;
+ position += border; // Move position down to origin of real image
+
+ // Assign row pointers
+ for (int j = height + border2; j--; y++, position += img->pitch) {
+ *y = position;
+ }
+ }
+
+ return img;
+}
+
+// Free the images
+void PyramidShort::freeImage(PyramidShort *image)
+{
+ if (image != NULL)
+ free(image);
+}
+
+// Calculate amount of storage needed taking into account the borders, etc.
+unsigned int PyramidShort::calcStorage(real width, real height, real border2, int levels, int *lines)
+{
+ int size;
+
+ *lines = size = 0;
+
+ while(levels--) {
+ size += (width + border2) * (height + border2);
+ *lines += height + border2;
+ width >>= 1;
+ height >>= 1;
+ }
+
+ return size;
+}
+
+void PyramidShort::BorderSpread(PyramidShort *pyr, int left, int right,
+ int top, int bot)
+{
+ int off, off2, height, h, w;
+ ImageTypeShort base;
+
+ if (left || right) {
+ off = pyr->border - left;
+ off2 = pyr->width + off + pyr->border - right - 1;
+ h = pyr->border - top;
+ height = pyr->height + (h << 1);
+ base = pyr->ptr[-h] - off;
+
+ // spread in X
+ for (h = height; h--; base += pyr->pitch) {
+ for (w = left; w--;)
+ base[-1 - w] = base[0];
+ for (w = right; w--;)
+ base[off2 + w + 1] = base[off2];
+ }
+ }
+
+ if (top || bot) {
+ // spread in Y
+ base = pyr->ptr[top - pyr->border] - pyr->border;
+ for (h = top; h--; base -= pyr->pitch) {
+ memcpy(base - pyr->pitch, base, pyr->pitch * sizeof(short));
+ }
+
+ base = pyr->ptr[pyr->height + pyr->border - bot] - pyr->border;
+ for (h = bot; h--; base += pyr->pitch) {
+ memcpy(base, base - pyr->pitch, pyr->pitch * sizeof(short));
+ }
+ }
+}
+
+void PyramidShort::BorderExpandOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr,
+ int mode)
+{
+ int i,j;
+ int off = in->border / 2;
+
+ // Vertical Filter
+ for (j = -off; j < in->height + off; j++) {
+ int j2 = j * 2;
+ for (i = -scr->border; i < scr->width + scr->border; i++) {
+ scr->ptr[j2][i] = (short)
+ ((6 * in->ptr[j][i] + (in->ptr[j-1][i] + in->ptr[j+1][i]) + 4) >> 3);
+ scr->ptr[j2+1][i] = (short)((in->ptr[j][i] + in->ptr[j+1][i] + 1) >> 1);
+ }
+ }
+
+ BorderSpread(scr, 0, 0, 3, 3);
+
+ // Horizontal Filter
+ for (i = -off; i < scr->width + off; i++) {
+ int i2 = i * 2;
+ for (j = -out->border; j < out->height + out->border; j++) {
+ out->ptr[j][i2] = (short) (out->ptr[j][i2] +
+ (mode * ((6 * scr->ptr[j][i] +
+ scr->ptr[j][i-1] + scr->ptr[j][i+1] + 4) >> 3)));
+ out->ptr[j][i2+1] = (short) (out->ptr[j][i2+1] +
+ (mode * ((scr->ptr[j][i] + scr->ptr[j][i+1] + 1) >> 1)));
+ }
+ }
+
+}
+
+int PyramidShort::BorderExpand(PyramidShort *pyr, int nlev, int mode)
+{
+ PyramidShort *tpyr = pyr + nlev - 1;
+ PyramidShort *scr = allocateImage(pyr[1].width, pyr[0].height, pyr->border);
+ if (scr == NULL) return 0;
+
+ if (mode > 0) {
+ // Expand and add (reconstruct from Laplacian)
+ for (; tpyr > pyr; tpyr--) {
+ scr->width = tpyr[0].width;
+ scr->height = tpyr[-1].height;
+ BorderExpandOdd(tpyr, tpyr - 1, scr, 1);
+ }
+ }
+ else if (mode < 0) {
+ // Expand and subtract (build Laplacian)
+ while ((pyr++) < tpyr) {
+ scr->width = pyr[0].width;
+ scr->height = pyr[-1].height;
+ BorderExpandOdd(pyr, pyr - 1, scr, -1);
+ }
+ }
+
+ freeImage(scr);
+ return 1;
+}
+
+void PyramidShort::BorderReduceOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr)
+{
+ ImageTypeShortBase *s, *ns, *ls, *p, *np;
+
+ int off = scr->border - 2;
+ s = scr->ptr[-scr->border] - (off >> 1);
+ ns = s + scr->pitch;
+ ls = scr->ptr[scr->height + scr->border - 1] + scr->pitch - (off >> 1);
+ int width = scr->width + scr->border;
+ p = in->ptr[-scr->border] - off;
+ np = p + in->pitch;
+
+ // treat it as if the whole thing were the image
+ for (; s < ls; s = ns, ns += scr->pitch, p = np, np += in->pitch) {
+ for (int w = width; w--; s++, p += 2) {
+ *s = (short)((((int) p[-2]) + ((int) p[2]) + 8 + // 1
+ ((((int) p[-1]) + ((int) p[1])) << 2) + // 4
+ ((int) *p) * 6) >> 4); // 6
+ }
+ }
+
+ BorderSpread(scr, 5, 4 + ((in->width ^ 1) & 1), 0, 0); //
+
+ s = out->ptr[-(off >> 1)] - out->border;
+ ns = s + out->pitch;
+ ls = s + out->pitch * (out->height + off);
+ p = scr->ptr[-off] - out->border;
+ int pitch = scr->pitch;
+ int pitch2 = pitch << 1;
+ np = p + pitch2;
+ for (; s < ls; s = ns, ns += out->pitch, p = np, np += pitch2) {
+ for (int w = out->pitch; w--; s++, p++) {
+ *s = (short)((((int) p[-pitch2]) + ((int) p[pitch2]) + 8 + // 1
+ ((((int) p[-pitch]) + ((int) p[pitch])) << 2) + // 4
+ ((int) *p) * 6) >> 4); // 6
+ }
+ }
+ BorderSpread(out, 0, 0, 5, 5);
+
+}
+
+int PyramidShort::BorderReduce(PyramidShort *pyr, int nlev)
+{
+ PyramidShort *scr = allocateImage(pyr[1].width, pyr[0].height, pyr->border);
+ if (scr == NULL)
+ return 0;
+
+ BorderSpread(pyr, pyr->border, pyr->border, pyr->border, pyr->border);
+ while (--nlev) {
+ BorderReduceOdd(pyr, pyr + 1, scr);
+ pyr++;
+ scr->width = pyr[1].width;
+ scr->height = pyr[0].height;
+ }
+
+ freeImage(scr);
+ return 1;
+}
diff --git a/jni/feature_mos/src/mosaic/Pyramid.h b/jni/feature_mos/src/mosaic/Pyramid.h
new file mode 100644
index 0000000..c5fe907
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/Pyramid.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Pyramid.h
+
+#ifndef PYRAMID_H
+#define PYRAMID_H
+
+#include "ImageUtils.h"
+
+typedef unsigned short int real;
+
+// Structure containing a packed pyramid of type ImageTypeShort. Used for pyramid
+// blending, among other things.
+
+class PyramidShort
+{
+
+public:
+
+ ImageTypeShort *ptr; // Pointer containing the image
+ real width, height; // Width and height of input images
+ real numChannels; // Number of channels in input images
+ real border; // border size
+ real pitch; // Pitch. Used for moving through image efficiently.
+
+ static PyramidShort *allocatePyramidPacked(real width, real height, real levels, real border = 0);
+ static PyramidShort *allocateImage(real width, real height, real border);
+ static void createPyramid(ImageType image, PyramidShort *pyramid, int last = 3 );
+ static void freeImage(PyramidShort *image);
+
+ static unsigned int calcStorage(real width, real height, real border2, int levels, int *lines);
+
+ static void BorderSpread(PyramidShort *pyr, int left, int right, int top, int bot);
+ static void BorderExpandOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr, int mode);
+ static int BorderExpand(PyramidShort *pyr, int nlev, int mode);
+ static int BorderReduce(PyramidShort *pyr, int nlev);
+ static void BorderReduceOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr);
+};
+
+#endif
diff --git a/jni/feature_mos/src/mosaic/trsMatrix.cpp b/jni/feature_mos/src/mosaic/trsMatrix.cpp
new file mode 100644
index 0000000..5fc6a86
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/trsMatrix.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// trsMatrix.cpp
+// $Id: trsMatrix.cpp,v 1.9 2011/06/17 13:35:48 mbansal Exp $
+
+#include "stdio.h"
+#include <math.h>
+#include "trsMatrix.h"
+
+void mult33d(double a[3][3], double b[3][3], double c[3][3])
+{
+ a[0][0] = b[0][0]*c[0][0] + b[0][1]*c[1][0] + b[0][2]*c[2][0];
+ a[0][1] = b[0][0]*c[0][1] + b[0][1]*c[1][1] + b[0][2]*c[2][1];
+ a[0][2] = b[0][0]*c[0][2] + b[0][1]*c[1][2] + b[0][2]*c[2][2];
+ a[1][0] = b[1][0]*c[0][0] + b[1][1]*c[1][0] + b[1][2]*c[2][0];
+ a[1][1] = b[1][0]*c[0][1] + b[1][1]*c[1][1] + b[1][2]*c[2][1];
+ a[1][2] = b[1][0]*c[0][2] + b[1][1]*c[1][2] + b[1][2]*c[2][2];
+ a[2][0] = b[2][0]*c[0][0] + b[2][1]*c[1][0] + b[2][2]*c[2][0];
+ a[2][1] = b[2][0]*c[0][1] + b[2][1]*c[1][1] + b[2][2]*c[2][1];
+ a[2][2] = b[2][0]*c[0][2] + b[2][1]*c[1][2] + b[2][2]*c[2][2];
+}
+
+
+// normProjMat33d
+// m = input matrix
+// return: result if successful
+int normProjMat33d(double m[3][3])
+{
+ double m22;
+
+ if(m[2][2] == 0.0)
+ {
+ return 0;
+}
+
+ m[0][0] /= m[2][2];
+ m[0][1] /= m[2][2];
+ m[0][2] /= m[2][2];
+ m[1][0] /= m[2][2];
+ m[1][1] /= m[2][2];
+ m[1][2] /= m[2][2];
+ m[2][0] /= m[2][2];
+ m[2][1] /= m[2][2];
+ m[2][2] = 1.0;
+
+ return 1;
+}
+
+// det33d
+// m = input matrix
+// returns: determinant
+double det33d(const double m[3][3])
+{
+ double result;
+
+ result = m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]);
+ result += m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]);
+ result += m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
+
+ return result;
+}
+
+// inv33d
+//
+void inv33d(const double m[3][3], double out[3][3])
+{
+ double det = det33d(m);
+
+ out[0][0] = (m[1][1]*m[2][2] - m[1][2]*m[2][1]) / det;
+ out[1][0] = (m[1][2]*m[2][0] - m[1][0]*m[2][2]) / det;
+ out[2][0] = (m[1][0]*m[2][1] - m[1][1]*m[2][0]) / det;
+
+ out[0][1] = (m[0][2]*m[2][1] - m[0][1]*m[2][2]) / det;
+ out[1][1] = (m[0][0]*m[2][2] - m[0][2]*m[2][0]) / det;
+ out[2][1] = (m[0][1]*m[2][0] - m[0][0]*m[2][1]) / det;
+
+ out[0][2] = (m[0][1]*m[1][2] - m[0][2]*m[1][1]) / det;
+ out[1][2] = (m[0][2]*m[1][0] - m[0][0]*m[1][2]) / det;
+ out[2][2] = (m[0][0]*m[1][1] - m[0][1]*m[1][0]) / det;
+}
diff --git a/jni/feature_mos/src/mosaic/trsMatrix.h b/jni/feature_mos/src/mosaic/trsMatrix.h
new file mode 100644
index 0000000..054cc33
--- /dev/null
+++ b/jni/feature_mos/src/mosaic/trsMatrix.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////
+// trsMatrix.h
+// $Id: trsMatrix.h,v 1.8 2011/06/17 13:35:48 mbansal Exp $
+
+#ifndef TRSMATRIX_H_
+#define TRSMATRIX_H_
+
+
+// Calculate the determinant of a matrix
+double det33d(const double m[3][3]);
+
+// Invert a matrix
+void inv33d(const double m[3][3], double out[3][3]);
+
+// Multiply a = b * c
+void mult33d(double a[3][3], double b[3][3], double c[3][3]);
+
+// Normalize matrix so matrix[2][2] is '1'
+int normProjMat33d(double m[3][3]);
+
+inline double ProjZ(double trs[3][3], double x, double y, double f)
+{
+ return ((trs)[2][0]*(x) + (trs)[2][1]*(y) + (trs)[2][2]*(f));
+}
+
+inline double ProjX(double trs[3][3], double x, double y, double z, double f)
+{
+ return (((trs)[0][0]*(x) + (trs)[0][1]*(y) + (trs)[0][2]*(f)) / (z));
+}
+
+inline double ProjY(double trs[3][3], double x, double y, double z, double f)
+{
+ return (((trs)[1][0]*(x) + (trs)[1][1]*(y) + (trs)[1][2]*(f)) / (z));
+}
+
+
+#endif