IARPA Janus  0.4.0
IARPA Janus Program API
iarpa_janus_io.h
1 /*******************************************************************************
2  * Copyright (c) 2013 Noblis, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and/or associated documentation files (the
6  * "Materials"), to deal in the Materials without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Materials, and to
9  * permit persons to whom the Materials are furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Materials.
14  *
15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22  ******************************************************************************/
23 
24 #ifndef IARPA_JANUS_IO_H
25 #define IARPA_JANUS_IO_H
26 
27 #include <iarpa_janus.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
45 #define JANUS_ASSERT(EXPRESSION) \
46 { \
47  const janus_error error = (EXPRESSION); \
48  if (error != JANUS_SUCCESS) { \
49  fprintf(stderr, "Janus error: %s\n\tFile: %s\n\tLine: %d\n", \
50  janus_error_to_string(error), \
51  __FILE__, \
52  __LINE__); \
53  abort(); \
54  } \
55 } \
56 
57 
62 #define JANUS_CHECK(EXPRESSION) \
63 { \
64  const janus_error error = (EXPRESSION); \
65  if (error != JANUS_SUCCESS) \
66  return error; \
67 } \
68 
69 
75 JANUS_EXPORT const char *janus_error_to_string(janus_error error);
76 
83 JANUS_EXPORT janus_error janus_error_from_string(const char *error);
84 
92 JANUS_EXPORT janus_error janus_read_image(const char *file_name,
93  janus_image *image);
94 
101 JANUS_EXPORT void janus_free_image(janus_image image);
102 
106 typedef struct janus_video_type *janus_video;
107 
115 JANUS_EXPORT janus_error janus_open_video(const char *file_name,
116  janus_video *video);
117 
125 JANUS_EXPORT janus_error janus_read_frame(janus_video video, janus_image *image);
126 
135 JANUS_EXPORT void janus_close_video(janus_video video);
136 
166 typedef const char *janus_metadata;
167 
176 JANUS_EXPORT janus_error janus_create_template(const char *data_path, janus_metadata metadata, janus_template *template_, janus_template_id *template_id);
177 
186 JANUS_EXPORT janus_error janus_create_templates(const char *data_path, janus_metadata metadata, const char *gallery_file, int verbose);
187 
196 JANUS_EXPORT janus_error janus_create_gallery(const char *data_path, janus_metadata metadata, janus_gallery_path gallery_path, int verbose);
197 
205 typedef const char *janus_matrix;
206 
218 JANUS_EXPORT janus_error janus_write_matrix(void *data, int rows, int columns, int is_mask, janus_metadata target, janus_metadata query, janus_matrix matrix);
219 
235 JANUS_EXPORT janus_error janus_evaluate_search(janus_gallery_path target, const char *query, janus_metadata target_metadata, janus_metadata query_metadata, janus_matrix simmat, janus_matrix mask, const char *candidate_lists, size_t num_requested_returns);
236 
249 JANUS_EXPORT janus_error janus_evaluate_verify(const char *target, const char *query, janus_metadata target_metadata, janus_metadata query_metadata, janus_matrix simmat, janus_matrix mask);
250 
263 JANUS_EXPORT janus_error janus_verify_pairwise(const char *comparisons_file, const char *templates_file, janus_metadata template_metadata, janus_matrix simmat, janus_matrix mask, const char *match_scores);
264 
270 {
271  size_t count;
272  double mean;
273  double stddev;
274 };
275 
281 {
303 };
304 
309 JANUS_EXPORT struct janus_metrics janus_get_metrics();
310 
316 JANUS_EXPORT void janus_print_metrics(struct janus_metrics metrics);
317 
320 #ifdef __cplusplus
321 }
322 #endif
323 
324 #endif /* IARPA_JANUS_IO_H */
struct janus_metric janus_template_size
KB.
Definition: iarpa_janus_io.h:292
struct janus_metric janus_search_speed
ms
Definition: iarpa_janus_io.h:289
struct janus_metric janus_initialize_template_speed
ms
Definition: iarpa_janus_io.h:282
A statistic.
Definition: iarpa_janus_io.h:269
JANUS_EXPORT janus_error janus_create_gallery(const char *data_path, janus_metadata metadata, janus_gallery_path gallery_path, int verbose)
High-level function for enrolling a gallery from a metadata file.
const char * janus_matrix
A dense binary 2D matrix file.
Definition: iarpa_janus_io.h:205
const char * janus_gallery_path
Galleries are represented in persistent storage as folders on disk.
Definition: iarpa_janus.h:637
JANUS_EXPORT void janus_free_image(janus_image image)
Frees the memory previously allocated for a janus_image.
int janus_failure_to_detect_count
Count of JANUS_FAILURE_TO_DETECT.
Definition: iarpa_janus_io.h:295
JANUS_EXPORT janus_error janus_read_frame(janus_video video, janus_image *image)
Returns the current frame and advances the video to the next frame.
size_t count
Number of samples.
Definition: iarpa_janus_io.h:271
JANUS_EXPORT janus_error janus_create_template(const char *data_path, janus_metadata metadata, janus_template *template_, janus_template_id *template_id)
High-level function for enrolling a template from a metadata file.
int janus_failure_to_enroll_count
Count of JANUS_FAILURE_TO_ENROLL.
Definition: iarpa_janus_io.h:297
JANUS_EXPORT janus_error janus_error_from_string(const char *error)
janus_error from string.
struct janus_metric janus_finalize_template_speed
ms
Definition: iarpa_janus_io.h:285
struct janus_metric janus_read_image_speed
ms
Definition: iarpa_janus_io.h:286
struct janus_metric janus_finalize_gallery_speed
ms
Definition: iarpa_janus_io.h:291
size_t janus_template_id
Unique identifier for a janus_flat_template.
Definition: iarpa_janus.h:628
JANUS_EXPORT janus_error janus_evaluate_verify(const char *target, const char *query, janus_metadata target_metadata, janus_metadata query_metadata, janus_matrix simmat, janus_matrix mask)
Create similarity and mask matricies from two galleries with calls to janus_verify.
JANUS_EXPORT janus_error janus_create_templates(const char *data_path, janus_metadata metadata, const char *gallery_file, int verbose)
High-level function for enrolling templates from a metadata file and writing templates to disk...
JANUS_EXPORT janus_error janus_read_image(const char *file_name, janus_image *image)
Read an image from disk.
JANUS_EXPORT janus_error janus_evaluate_search(janus_gallery_path target, const char *query, janus_metadata target_metadata, janus_metadata query_metadata, janus_matrix simmat, janus_matrix mask, const char *candidate_lists, size_t num_requested_returns)
Create similarity and mask matricies from two galleries with calls to janus_search.
JANUS_EXPORT void janus_print_metrics(struct janus_metrics metrics)
Print metrics to stdout.
JANUS_EXPORT janus_error janus_write_matrix(void *data, int rows, int columns, int is_mask, janus_metadata target, janus_metadata query, janus_matrix matrix)
Utility function for creating a janus_matrix.
struct janus_metric janus_verify_speed
ms
Definition: iarpa_janus_io.h:288
struct janus_metric janus_free_image_speed
ms
Definition: iarpa_janus_io.h:287
JANUS_EXPORT struct janus_metrics janus_get_metrics()
Retrieve and reset performance metrics.
struct janus_metric janus_augment_speed
ms
Definition: iarpa_janus_io.h:284
double stddev
Sample standard deviation.
Definition: iarpa_janus_io.h:273
JANUS_EXPORT janus_error janus_verify_pairwise(const char *comparisons_file, const char *templates_file, janus_metadata template_metadata, janus_matrix simmat, janus_matrix mask, const char *match_scores)
High-level function for executing a list of template comparisons.
int janus_missing_attributes_count
Count of JANUS_MISSING_ATTRIBUTES.
Definition: iarpa_janus_io.h:293
const char * janus_metadata
File name for a Janus Metadata File.
Definition: iarpa_janus_io.h:166
double mean
Sample average.
Definition: iarpa_janus_io.h:272
JANUS_EXPORT janus_error janus_open_video(const char *file_name, janus_video *video)
Returns a video ready for reading.
int janus_other_errors_count
Count of janus_error excluding JANUS_MISSING_ATTRIBUTES, JANUS_FAILURE_TO_ENROLL, and JANUS_SUCCESS...
Definition: iarpa_janus_io.h:299
Common representation for still images and video frames.
Definition: iarpa_janus.h:225
struct janus_metric janus_detection_speed
ms
Definition: iarpa_janus_io.h:283
struct janus_metric janus_gallery_size_speed
ms
Definition: iarpa_janus_io.h:290
janus_error
Return type for functions that indicate an error status.
Definition: iarpa_janus.h:163
JANUS_EXPORT const char * janus_error_to_string(janus_error error)
janus_error to string.
struct janus_template_type * janus_template
Contains the recognition information for an object.
Definition: iarpa_janus.h:502
struct janus_video_type * janus_video
Handle to a private video decoding type.
Definition: iarpa_janus_io.h:106
JANUS_EXPORT void janus_close_video(janus_video video)
Closes a video previously opened by janus_open_video.
All statistics.
Definition: iarpa_janus_io.h:280