summaryrefslogtreecommitdiff
path: root/include/ia_imaging/ia_montage.h
blob: 21602745f31424d0377af1c215d560f0f77d3b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (C) 2015 - 2017 Intel Corporation.
 *
 * 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 _IA_MONTAGE_H_
#define _IA_MONTAGE_H_

/** @file ia_montage.h
 * This file declares structures and APIs of image montage engine.
 */

#include "ia_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Image montage state. This is the handle for IM engine.
 */
typedef struct {
    ia_frame *output_image;                             /**< Allocated and managed internally, result image will be stored here. */
} ia_montage_state;


/** @brief Parameters for ia montage engine.
 * Used by ia_montage_set_parameter() and ia_montage_get_parameter() to indicate runtime engine configuration.
 */
typedef struct {
    int32_t search_region_margin_percentage;            /**< Indicates how much enlarged area to be considered when it crops the object image patch from sub image. Default is 20. */
} ia_montage_parameters;

/** @brief Initialize Image Montage engine
 *
 *  @param env [IN] Platform environment parameters.
 *
 * This function instantiates and initializes the Image Montage Engine.
 */
LIBEXPORT
ia_montage_state *
ia_montage_init(const ia_env *env);

/** @brief Destroy Image Montage Engine.
 */
LIBEXPORT
void
ia_montage_uninit(ia_montage_state *state);

/** @brief Initialize existing Image Montage engine.
 */
LIBEXPORT
void
ia_montage_reinit(ia_montage_state *state);

/** @brief Get version information of the Image Montage Engine.
 */
LIBEXPORT
ia_version
ia_montage_get_version(void);

/** @brief Set the parameters.
 *
 *  @param ms       [IN] Image Montage engine context.
 *  @param params   [IN] the parameter struct.
 *
 * Set ia_montage parameters to the engine context. The params is supposed to be filled by ia_montage_get_parameters().
 */
LIBEXPORT
ia_err
ia_montage_set_parameter(ia_montage_state *ms, const ia_montage_parameters *params);

/** @brief Get the parameters.
 *
 *  @param ms       [IN] Image Montage engine context.
 *  @param params   [IN/OUT] the parameter struct.
 *
 * Get ia_montage parameters from the engine context. The params must be allocated before calling this function. The members
 * would be filled after it returns.
 */
LIBEXPORT
ia_err
ia_montage_get_parameter(ia_montage_state *ms, ia_montage_parameters *params);

/** @brief Set the main image.
 *
 *  @param ms          [IN] Image Montage engine context.
 *  @param main_frame  [IN] Main image.
 *  @param objects     [IN] an array of the objects coordinates.
 *  @param num_objects [IN] the number of objects.
 *
 * The main image is labelled as the "background" for Image Montage.
 * Various objects are necessary to consider the overlapping between each object. Objects could be faces for general use-cases.
 * It is required to call this apposed to ia_montage_set_sub_images(), prior to composing.
 */

LIBEXPORT
ia_err
ia_montage_set_main_image(ia_montage_state *ms, const ia_frame *main_frame, ia_rectangle* objects, int32_t num_objects);

/** @brief Set the sub image where the object patches come from.
 *
 *  @param ms          [IN] Image Montage engine context.
 *  @param sub_frame   [IN] Sub image.
 *  @param objects     [IN] the coordinates of objects.
 *  @param num_objects [IN] the number of objects.
 *
 * The main image is labelled as the "background" for Image Montage.
 * Various objects are necessary to consider the overlapping between each object. Objects could be faces for general use-cases.
 * It is required to call this apposed to ia_montage_set_sub_images(), prior to composing.
 * It is fine to call this before than ia_montage_set_main_image().
 */
LIBEXPORT
ia_err
ia_montage_set_sub_image(ia_montage_state *ms, const ia_frame *sub_frame, ia_rectangle* objects, int32_t num_objects);

/** @brief Compose the image montage, cropping from the sub image, pasting to the main image.
 *
 *  @param ms           [IN] Image Montage engine context.
 *  @param idx_on_main  [IN] the index of the object given along with main image.
 *  @param idx_on_sub   [IN] the index of the object given along with sub image.
 *
 * This is to combine two images(main, sub), cropping an object image patch placed on 'idx_on_sub'th place of sub objects array,
 * overlaying it onto the place of 'idx_on_image' th of main objects array.
 * The composed image would be in the engine context.
 * Every time this function is called, the result image will be newly composed from main/sub images and the previous image will gone.
 * You should call ia_montage_set_main_image() again with the result image, in order to paste a new object on the result image,
 *
 */
LIBEXPORT
ia_err
ia_montage_compose(ia_montage_state *ms, int32_t idx_on_main, int32_t idx_on_sub);




#ifdef __cplusplus
}
#endif


#endif /* _IA_MONTAGE_H_ */