Turi Create  4.0
object_detection.hpp
1 #ifndef TURI_ANNOTATIONS_OBJECT_DETECTION_HPP
2 #define TURI_ANNOTATIONS_OBJECT_DETECTION_HPP
3 
4 #include <chrono>
5 #include <future>
6 #include <iostream>
7 #include <thread>
8 
9 #include <visualization/annotation/annotation_base.hpp>
10 #include <model_server/lib/variant.hpp>
11 #include <toolkits/nearest_neighbors/unity_nearest_neighbors.hpp>
12 
13 #include "build/format/cpp/annotate.pb.h"
14 #include "build/format/cpp/data.pb.h"
15 
16 namespace turi {
17 namespace annotate {
18 
19 class ObjectDetection : public AnnotationBase {
20 public:
21  ObjectDetection() : AnnotationBase(){};
22  ObjectDetection(const std::shared_ptr<unity_sframe> &data,
23  const std::vector<std::string> &data_columns,
24  const std::string &annotation_column);
25 
26  ~ObjectDetection(){};
27 
28  annotate_spec::MetaData metaData() override;
29 
30  annotate_spec::Data getItems(size_t start, size_t end) override;
31 
32  annotate_spec::Annotations getAnnotations(size_t start, size_t end) override;
33 
34  bool setAnnotations(const annotate_spec::Annotations &annotations) override;
35 
36  void cast_annotations() override;
37 
38  void background_work() override;
39 
40  void addAnnotationColumn() override;
41 
42  void checkDataSet() override;
43 
44  annotate_spec::Similarity get_similar_items(size_t index,
45  size_t k = 7) override;
46 
47  BEGIN_CLASS_MEMBER_REGISTRATION("ObjectDetection");
48  IMPORT_BASE_CLASS_REGISTRATION(AnnotationBase);
50 private:
51  flex_dict _parse_bounding_boxes(annotate_spec::Label label);
52  void _addAnnotationToSFrame(size_t index, flex_list label);
53 };
54 
55 std::shared_ptr<ObjectDetection>
56 create_object_detection_annotation(const std::shared_ptr<unity_sframe> &data,
57  const std::vector<std::string> &data_columns,
58  const std::string &annotation_column);
59 
60 } // namespace annotate
61 } // namespace turi
62 
63 #endif
#define BEGIN_CLASS_MEMBER_REGISTRATION(python_facing_classname)
#define IMPORT_BASE_CLASS_REGISTRATION(base_class)
#define END_CLASS_MEMBER_REGISTRATION
std::vector< std::pair< flexible_type, flexible_type > > flex_dict
std::vector< flexible_type > flex_list