Add option to specify object classes list file
authorYuan Zhao <yuanzhao@ti.com>
Wed, 31 Oct 2018 21:53:30 +0000 (16:53 -0500)
committerYuan Zhao <yuanzhao@ti.com>
Thu, 1 Nov 2018 19:46:09 +0000 (14:46 -0500)
- so that user can specify a different object classes list file
  without re-compiling the application.
- MCT-1081

17 files changed:
examples/classification/Makefile
examples/common/object_classes.cpp [moved from examples/segmentation/object_classes.cpp with 51% similarity]
examples/common/object_classes.h [moved from examples/segmentation/object_classes.h with 77% similarity]
examples/common/video_utils.cpp
examples/common/video_utils.h
examples/imagenet/Makefile
examples/imagenet/imagenet_classes.cpp [deleted file]
examples/imagenet/imagenet_classes.h [deleted file]
examples/imagenet/imagenet_objects.json [new file with mode: 0644]
examples/imagenet/main.cpp
examples/mcbench/main.cpp
examples/segmentation/Makefile
examples/segmentation/jseg21_objects.json [new file with mode: 0644]
examples/segmentation/main.cpp
examples/ssd_multibox/Makefile
examples/ssd_multibox/jdetnet_objects.json [new file with mode: 0644]
examples/ssd_multibox/main.cpp

index 441b8424167afe247dd5ef08a5d28de4b7e07a3b..70308ccab65658c2937cef355ce50851aa85a872 100644 (file)
@@ -34,7 +34,8 @@ LIBS     += -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio\
 SOURCES = main.cpp findclasses.cpp
 
 $(EXE): $(TIDL_API_LIB) $(HEADERS) $(SOURCES)
-       $(CXX) $(CXXFLAGS) $(SOURCES) $(TIDL_API_LIB) $(LDFLAGS) $(LIBS) -o $@
+       $(CXX) $(CXXFLAGS) $(SOURCES) $(TIDL_API_LIB) $(TIDL_API_LIB_IMGUTIL) \
+               $(LDFLAGS) $(LIBS) -o $@
 
 clean::
        $(RM) -f $(EXE)
similarity index 51%
rename from examples/segmentation/object_classes.cpp
rename to examples/common/object_classes.cpp
index 35aebf744d338cc841813024d96747355e25d692..66e68930e8e50f020ecd01140c768142546c1955 100644 (file)
 
 #include "object_classes.h"
 
-object_class_table_t jseg21_table =
-{
-    5,
-    {
-        { "background",       { 127, 127, 127 } },
-        { "road",             {   0, 255,   0 } },
-        { "pedestrian",       { 255,   0,   0 } },
-        { "road sign",        { 255, 255,   0 } },
-        { "vehicle",          {   0,   0, 255 } },
-        { "unknown",          {   0,   0,   0 } }    /* guard */
-    }
-};
+extern "C" {
+    #include <json-c/json.h>
+}
+
 
-object_class_table_t jdetnet_table =
+ObjectClasses::ObjectClasses(const std::string& json_file) : num_classes_m(0)
 {
-    4,
+    struct json_object *ocs = json_object_from_file(json_file.c_str());
+    if (ocs != nullptr)
     {
-        { "some class 1",     { 255,   0, 255 } },
-        { "pedestrian",       { 255,   0,   0 } },
-        { "road sign",        { 255, 255,   0 } },
-        { "vehicle",          {   0,   0, 255 } },
-        { "unknown",          {   0,   0,   0 } }    /* guard */
+        struct json_object *net_name, *objs, *obj, *label, *color;
+        if (json_object_object_get_ex(ocs, "network", &net_name))
+            network_name_m = json_object_get_string(net_name);
+
+        if (json_object_object_get_ex(ocs, "objects", &objs))
+        {
+            num_classes_m = json_object_array_length(objs);
+            for (unsigned int i = 0; i < num_classes_m; i++)
+            {
+                obj = json_object_array_get_idx(objs, i);
+
+                std::string s_label;
+                if (json_object_object_get_ex(obj, "label", &label))
+                    s_label = json_object_get_string(label);
+                else
+                    s_label = "label" + std::to_string(i);
+
+                unsigned char b, g, r;
+                if (json_object_object_get_ex(obj, "color_bgr", &color))
+                {
+                    b = json_object_get_int(json_object_array_get_idx(color,0));
+                    g = json_object_get_int(json_object_array_get_idx(color,1));
+                    r = json_object_get_int(json_object_array_get_idx(color,2));
+                }
+                else
+                    b = g = r = 255;
+
+                classes_m.emplace_back(s_label, b, g, r);
+            }
+        }
+
+        json_object_put(ocs);  // decrement refcount and free
     }
-};
 
-object_class_table_t* GetObjectClassTable(std::string &config)
-{
-     if (config.compare(0, 6, "jseg21") == 0)  return &jseg21_table;
-     else if (config == "jdetnet")             return &jdetnet_table;
-     else                                      return nullptr;
+    classes_m.emplace_back("unknown", 0, 0, 0);  // sentinel
 }
 
-object_class_t* GetObjectClass(object_class_table_t *table, int index)
+const ObjectClass& ObjectClasses::At(unsigned int index)
 {
-    if (index < 0 || (unsigned int)index >= table->num_classes)  index = table->num_classes;
-    return & (table->classes[index]);
+    if (index < num_classes_m)  return classes_m[index];
+    else                        return classes_m[num_classes_m];
 }
 
similarity index 77%
rename from examples/segmentation/object_classes.h
rename to examples/common/object_classes.h
index 2a2fce7631519a20bd82d147a5d9741dca732bba..cc6a7cb8b96a3760b706efbfe03d0d7038503846 100644 (file)
 #include <string>
 #include <vector>
 
-typedef struct {
-    const char *label;
+struct ObjectClass {
+    std::string       label;
     struct {
-        unsigned char red;
-        unsigned char green;
         unsigned char blue;
+        unsigned char green;
+        unsigned char red;
     } color;
-} object_class_t;
 
-typedef struct {
-    unsigned int                 num_classes;
-    std::vector<object_class_t>  classes;
-} object_class_table_t;
+    ObjectClass(const std::string& l, unsigned char b, unsigned char g,
+                unsigned char r) : label { l }, color { b, g, r} {}
+};
+
+class ObjectClasses {
+  public:
+    ObjectClasses(const std::string& json_file);
+    const ObjectClass& At(unsigned int index);
+
+    unsigned int       GetNumClasses()  { return num_classes_m; }
+    const std::string& GetNetworkName() { return network_name_m; }
 
-extern object_class_table_t* GetObjectClassTable(std::string &config);
-extern object_class_t*       GetObjectClass(object_class_table_t *table,
-                                         int index);
+  private:
+    unsigned int              num_classes_m;
+    std::string               network_name_m;
+    std::vector<ObjectClass>  classes_m;
+};
 
 #endif
index 3330b90856ba18e9b2148c0693f95ffa8b3c113c..0eba48531eed81591610b88376d679d40322cc82 100644 (file)
@@ -51,6 +51,7 @@ bool ProcessArgs(int argc, char *argv[], cmdline_opts_t& opts)
         {"num_layers_groups", required_argument, 0, 'g'},
         {"num_frames",   required_argument, 0, 'f'},
         {"input_file",   required_argument, 0, 'i'},
+        {"object_classes_list_file",   required_argument, 0, 'l'},
         {"output_width", required_argument, 0, 'w'},
         {"help",         no_argument,       0, 'h'},
         {"verbose",      no_argument,       0, 'v'},
@@ -61,7 +62,7 @@ bool ProcessArgs(int argc, char *argv[], cmdline_opts_t& opts)
 
     while (true)
     {
-        int c = getopt_long(argc, argv, "c:d:e:g:f:i:w:hv", long_options,
+        int c = getopt_long(argc, argv, "c:d:e:g:f:i:l:w:hv", long_options,
                             &option_index);
 
         if (c == -1)
@@ -93,6 +94,9 @@ bool ProcessArgs(int argc, char *argv[], cmdline_opts_t& opts)
             case 'i': opts.input_file = optarg;
                       break;
 
+            case 'l': opts.object_classes_list_file = optarg;
+                      break;
+
             case 'w': opts.output_width = atoi(optarg);
                       assert (opts.output_width > 0);
                       break;
index 30d751da886b62dba260e7ff502c729cf6f683b5..5335b4955eb2f5eee2dda5182f84d557e8c3a1d9 100644 (file)
@@ -42,6 +42,7 @@ typedef struct cmdline_opts_t_ {
   uint32_t    num_layers_groups;
   uint32_t    num_frames;
   std::string input_file;
+  std::string object_classes_list_file;
   uint32_t    output_width;
   bool        verbose;
   bool        is_camera_input;
index 637cd07e940077a232f6bcfb486753f56834a160..954335a2e56b8f318e77a9dd6ee426b6492ce64f 100644 (file)
@@ -30,8 +30,9 @@ include ../make.common
 
 LIBS     += -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio\
                        -lopencv_imgproc -lopencv_core
+LIBS     += -ljson-c
 
-SOURCES = main.cpp imagenet_classes.cpp ../common/utils.cpp \
+SOURCES = main.cpp ../common/object_classes.cpp ../common/utils.cpp \
           ../common/video_utils.cpp
 
 $(EXE): $(TIDL_API_LIB) $(TIDL_API_LIB_IMGUTIL) $(HEADERS) $(SOURCES)
diff --git a/examples/imagenet/imagenet_classes.cpp b/examples/imagenet/imagenet_classes.cpp
deleted file mode 100644 (file)
index abd5f33..0000000
+++ /dev/null
@@ -1,1032 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
- *   All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions are met:
- *       * Redistributions of source code must retain the above copyright
- *         notice, this list of conditions and the following disclaimer.
- *       * Redistributions in binary form must reproduce the above copyright
- *         notice, this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *       * Neither the name of Texas Instruments Incorporated nor the
- *         names of its contributors may be used to endorse or promote products
- *         derived from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- *   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- *   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- *   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- *   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- *   THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
-#include "imagenet_classes.h"
-
-std::string imagenet_classes[NUM_IMAGENET_CLASSES] = {
-"tench",
-"goldfish",
-"great_white_shark",
-"tiger_shark",
-"hammerhead",
-"electric_ray",
-"stingray",
-"cock",
-"hen",
-"ostrich",
-"brambling",
-"goldfinch",
-"house_finch",
-"junco",
-"indigo_bunting",
-"robin",
-"bulbul",
-"jay",
-"magpie",
-"chickadee",
-"water_ouzel",
-"kite",
-"bald_eagle",
-"vulture",
-"great_grey_owl",
-"European_fire_salamander",
-"common_newt",
-"eft",
-"spotted_salamander",
-"axolotl",
-"bullfrog",
-"tree_frog",
-"tailed_frog",
-"loggerhead",
-"leatherback_turtle",
-"mud_turtle",
-"terrapin",
-"box_turtle",
-"banded_gecko",
-"common_iguana",
-"American_chameleon",
-"whiptail",
-"agama",
-"frilled_lizard",
-"alligator_lizard",
-"Gila_monster",
-"green_lizard",
-"African_chameleon",
-"Komodo_dragon",
-"African_crocodile",
-"American_alligator",
-"triceratops",
-"thunder_snake",
-"ringneck_snake",
-"hognose_snake",
-"green_snake",
-"king_snake",
-"garter_snake",
-"water_snake",
-"vine_snake",
-"night_snake",
-"boa_constrictor",
-"rock_python",
-"Indian_cobra",
-"green_mamba",
-"sea_snake",
-"horned_viper",
-"diamondback",
-"sidewinder",
-"trilobite",
-"harvestman",
-"scorpion",
-"black_and_gold_garden_spider",
-"barn_spider",
-"garden_spider",
-"black_widow",
-"tarantula",
-"wolf_spider",
-"tick",
-"centipede",
-"black_grouse",
-"ptarmigan",
-"ruffed_grouse",
-"prairie_chicken",
-"peacock",
-"quail",
-"partridge",
-"African_grey",
-"macaw",
-"sulphur-crested_cockatoo",
-"lorikeet",
-"coucal",
-"bee_eater",
-"hornbill",
-"hummingbird",
-"jacamar",
-"toucan",
-"drake",
-"red-breasted_merganser",
-"goose",
-"black_swan",
-"tusker",
-"echidna",
-"platypus",
-"wallaby",
-"koala",
-"wombat",
-"jellyfish",
-"sea_anemone",
-"brain_coral",
-"flatworm",
-"nematode",
-"conch",
-"snail",
-"slug",
-"sea_slug",
-"chiton",
-"chambered_nautilus",
-"Dungeness_crab",
-"rock_crab",
-"fiddler_crab",
-"king_crab",
-"American_lobster",
-"spiny_lobster",
-"crayfish",
-"hermit_crab",
-"isopod",
-"white_stork",
-"black_stork",
-"spoonbill",
-"flamingo",
-"little_blue_heron",
-"American_egret",
-"bittern",
-"crane",
-"limpkin",
-"European_gallinule",
-"American_coot",
-"bustard",
-"ruddy_turnstone",
-"red-backed_sandpiper",
-"redshank",
-"dowitcher",
-"oystercatcher",
-"pelican",
-"king_penguin",
-"albatross",
-"grey_whale",
-"killer_whale",
-"dugong",
-"sea_lion",
-"Chihuahua",
-"Japanese_spaniel",
-"Maltese_dog",
-"Pekinese",
-"Shih-Tzu",
-"Blenheim_spaniel",
-"papillon",
-"toy_terrier",
-"Rhodesian_ridgeback",
-"Afghan_hound",
-"basset",
-"beagle",
-"bloodhound",
-"bluetick",
-"black-and-tan_coonhound",
-"Walker_hound",
-"English_foxhound",
-"redbone",
-"borzoi",
-"Irish_wolfhound",
-"Italian_greyhound",
-"whippet",
-"Ibizan_hound",
-"Norwegian_elkhound",
-"otterhound",
-"Saluki",
-"Scottish_deerhound",
-"Weimaraner",
-"Staffordshire_bullterrier",
-"American_Staffordshire_terrier",
-"Bedlington_terrier",
-"Border_terrier",
-"Kerry_blue_terrier",
-"Irish_terrier",
-"Norfolk_terrier",
-"Norwich_terrier",
-"Yorkshire_terrier",
-"wire-haired_fox_terrier",
-"Lakeland_terrier",
-"Sealyham_terrier",
-"Airedale",
-"cairn",
-"Australian_terrier",
-"Dandie_Dinmont",
-"Boston_bull",
-"miniature_schnauzer",
-"giant_schnauzer",
-"standard_schnauzer",
-"Scotch_terrier",
-"Tibetan_terrier",
-"silky_terrier",
-"soft-coated_wheaten_terrier",
-"West_Highland_white_terrier",
-"Lhasa",
-"flat-coated_retriever",
-"curly-coated_retriever",
-"golden_retriever",
-"Labrador_retriever",
-"Chesapeake_Bay_retriever",
-"German_short-haired_pointer",
-"vizsla",
-"English_setter",
-"Irish_setter",
-"Gordon_setter",
-"Brittany_spaniel",
-"clumber",
-"English_springer",
-"Welsh_springer_spaniel",
-"cocker_spaniel",
-"Sussex_spaniel",
-"Irish_water_spaniel",
-"kuvasz",
-"schipperke",
-"groenendael",
-"malinois",
-"briard",
-"kelpie",
-"komondor",
-"Old_English_sheepdog",
-"Shetland_sheepdog",
-"collie",
-"Border_collie",
-"Bouvier_des_Flandres",
-"Rottweiler",
-"German_shepherd",
-"Doberman",
-"miniature_pinscher",
-"Greater_Swiss_Mountain_dog",
-"Bernese_mountain_dog",
-"Appenzeller",
-"EntleBucher",
-"boxer",
-"bull_mastiff",
-"Tibetan_mastiff",
-"French_bulldog",
-"Great_Dane",
-"Saint_Bernard",
-"Eskimo_dog",
-"malamute",
-"Siberian_husky",
-"dalmatian",
-"affenpinscher",
-"basenji",
-"pug",
-"Leonberg",
-"Newfoundland",
-"Great_Pyrenees",
-"Samoyed",
-"Pomeranian",
-"chow",
-"keeshond",
-"Brabancon_griffon",
-"Pembroke",
-"Cardigan",
-"toy_poodle",
-"miniature_poodle",
-"standard_poodle",
-"Mexican_hairless",
-"timber_wolf",
-"white_wolf",
-"red_wolf",
-"coyote",
-"dingo",
-"dhole",
-"African_hunting_dog",
-"hyena",
-"red_fox",
-"kit_fox",
-"Arctic_fox",
-"grey_fox",
-"tabby",
-"tiger_cat",
-"Persian_cat",
-"Siamese_cat",
-"Egyptian_cat",
-"cougar",
-"lynx",
-"leopard",
-"snow_leopard",
-"jaguar",
-"lion",
-"tiger",
-"cheetah",
-"brown_bear",
-"American_black_bear",
-"ice_bear",
-"sloth_bear",
-"mongoose",
-"meerkat",
-"tiger_beetle",
-"ladybug",
-"ground_beetle",
-"long-horned_beetle",
-"leaf_beetle",
-"dung_beetle",
-"rhinoceros_beetle",
-"weevil",
-"fly",
-"bee",
-"ant",
-"grasshopper",
-"cricket",
-"walking_stick",
-"cockroach",
-"mantis",
-"cicada",
-"leafhopper",
-"lacewing",
-"dragonfly",
-"damselfly",
-"admiral",
-"ringlet",
-"monarch",
-"cabbage_butterfly",
-"sulphur_butterfly",
-"lycaenid",
-"starfish",
-"sea_urchin",
-"sea_cucumber",
-"wood_rabbit",
-"hare",
-"Angora",
-"hamster",
-"porcupine",
-"fox_squirrel",
-"marmot",
-"beaver",
-"guinea_pig",
-"sorrel",
-"zebra",
-"hog",
-"wild_boar",
-"warthog",
-"hippopotamus",
-"ox",
-"water_buffalo",
-"bison",
-"ram",
-"bighorn",
-"ibex",
-"hartebeest",
-"impala",
-"gazelle",
-"Arabian_camel",
-"llama",
-"weasel",
-"mink",
-"polecat",
-"black-footed_ferret",
-"otter",
-"skunk",
-"badger",
-"armadillo",
-"three-toed_sloth",
-"orangutan",
-"gorilla",
-"chimpanzee",
-"gibbon",
-"siamang",
-"guenon",
-"patas",
-"baboon",
-"macaque",
-"langur",
-"colobus",
-"proboscis_monkey",
-"marmoset",
-"capuchin",
-"howler_monkey",
-"titi",
-"spider_monkey",
-"squirrel_monkey",
-"Madagascar_cat",
-"indri",
-"Indian_elephant",
-"African_elephant",
-"lesser_panda",
-"giant_panda",
-"barracouta",
-"eel",
-"coho",
-"rock_beauty",
-"anemone_fish",
-"sturgeon",
-"gar",
-"lionfish",
-"puffer",
-"abacus",
-"abaya",
-"academic_gown",
-"accordion",
-"acoustic_guitar",
-"aircraft_carrier",
-"airliner",
-"airship",
-"altar",
-"ambulance",
-"amphibian",
-"analog_clock",
-"apiary",
-"apron",
-"ashcan",
-"assault_rifle",
-"backpack",
-"bakery",
-"balance_beam",
-"balloon",
-"ballpoint",
-"Band_Aid",
-"banjo",
-"bannister",
-"barbell",
-"barber_chair",
-"barbershop",
-"barn",
-"barometer",
-"barrel",
-"barrow",
-"baseball",
-"basketball",
-"bassinet",
-"bassoon",
-"bathing_cap",
-"bath_towel",
-"bathtub",
-"beach_wagon",
-"beacon",
-"beaker",
-"bearskin",
-"beer_bottle",
-"beer_glass",
-"bell_cote",
-"bib",
-"bicycle-built-for-two",
-"bikini",
-"binder",
-"binoculars",
-"birdhouse",
-"boathouse",
-"bobsled",
-"bolo_tie",
-"bonnet",
-"bookcase",
-"bookshop",
-"bottlecap",
-"bow",
-"bow_tie",
-"brass",
-"brassiere",
-"breakwater",
-"breastplate",
-"broom",
-"bucket",
-"buckle",
-"bulletproof_vest",
-"bullet_train",
-"butcher_shop",
-"cab",
-"caldron",
-"candle",
-"cannon",
-"canoe",
-"can_opener",
-"cardigan",
-"car_mirror",
-"carousel",
-"carpenter's_kit",
-"carton",
-"car_wheel",
-"cash_machine",
-"cassette",
-"cassette_player",
-"castle",
-"catamaran",
-"CD_player",
-"cello",
-"cellular_telephone",
-"chain",
-"chainlink_fence",
-"chain_mail",
-"chain_saw",
-"chest",
-"chiffonier",
-"chime",
-"china_cabinet",
-"Christmas_stocking",
-"church",
-"cinema",
-"cleaver",
-"cliff_dwelling",
-"cloak",
-"clog",
-"cocktail_shaker",
-"coffee_mug",
-"coffeepot",
-"coil",
-"combination_lock",
-"computer_keyboard",
-"confectionery",
-"container_ship",
-"convertible",
-"corkscrew",
-"cornet",
-"cowboy_boot",
-"cowboy_hat",
-"cradle",
-"crane",
-"crash_helmet",
-"crate",
-"crib",
-"Crock_Pot",
-"croquet_ball",
-"crutch",
-"cuirass",
-"dam",
-"desk",
-"desktop_computer",
-"dial_telephone",
-"diaper",
-"digital_clock",
-"digital_watch",
-"dining_table",
-"dishrag",
-"dishwasher",
-"disk_brake",
-"dock",
-"dogsled",
-"dome",
-"doormat",
-"drilling_platform",
-"drum",
-"drumstick",
-"dumbbell",
-"Dutch_oven",
-"electric_fan",
-"electric_guitar",
-"electric_locomotive",
-"entertainment_center",
-"envelope",
-"espresso_maker",
-"face_powder",
-"feather_boa",
-"file",
-"fireboat",
-"fire_engine",
-"fire_screen",
-"flagpole",
-"flute",
-"folding_chair",
-"football_helmet",
-"forklift",
-"fountain",
-"fountain_pen",
-"four-poster",
-"freight_car",
-"French_horn",
-"frying_pan",
-"fur_coat",
-"garbage_truck",
-"gasmask",
-"gas_pump",
-"goblet",
-"go-kart",
-"golf_ball",
-"golfcart",
-"gondola",
-"gong",
-"gown",
-"grand_piano",
-"greenhouse",
-"grille",
-"grocery_store",
-"guillotine",
-"hair_slide",
-"hair_spray",
-"half_track",
-"hammer",
-"hamper",
-"hand_blower",
-"hand-held_computer",
-"handkerchief",
-"hard_disc",
-"harmonica",
-"harp",
-"harvester",
-"hatchet",
-"holster",
-"home_theater",
-"honeycomb",
-"hook",
-"hoopskirt",
-"horizontal_bar",
-"horse_cart",
-"hourglass",
-"iPod",
-"iron",
-"jack-o'-lantern",
-"jean",
-"jeep",
-"jersey",
-"jigsaw_puzzle",
-"jinrikisha",
-"joystick",
-"kimono",
-"knee_pad",
-"knot",
-"lab_coat",
-"ladle",
-"lampshade",
-"laptop",
-"lawn_mower",
-"lens_cap",
-"letter_opener",
-"library",
-"lifeboat",
-"lighter",
-"limousine",
-"liner",
-"lipstick",
-"Loafer",
-"lotion",
-"loudspeaker",
-"loupe",
-"lumbermill",
-"magnetic_compass",
-"mailbag",
-"mailbox",
-"maillot",
-"maillot",
-"manhole_cover",
-"maraca",
-"marimba",
-"mask",
-"matchstick",
-"maypole",
-"maze",
-"measuring_cup",
-"medicine_chest",
-"megalith",
-"microphone",
-"microwave",
-"military_uniform",
-"milk_can",
-"minibus",
-"miniskirt",
-"minivan",
-"missile",
-"mitten",
-"mixing_bowl",
-"mobile_home",
-"Model_T",
-"modem",
-"monastery",
-"monitor",
-"moped",
-"mortar",
-"mortarboard",
-"mosque",
-"mosquito_net",
-"motor_scooter",
-"mountain_bike",
-"mountain_tent",
-"mouse",
-"mousetrap",
-"moving_van",
-"muzzle",
-"nail",
-"neck_brace",
-"necklace",
-"nipple",
-"notebook",
-"obelisk",
-"oboe",
-"ocarina",
-"odometer",
-"oil_filter",
-"organ",
-"oscilloscope",
-"overskirt",
-"oxcart",
-"oxygen_mask",
-"packet",
-"paddle",
-"paddlewheel",
-"padlock",
-"paintbrush",
-"pajama",
-"palace",
-"panpipe",
-"paper_towel",
-"parachute",
-"parallel_bars",
-"park_bench",
-"parking_meter",
-"passenger_car",
-"patio",
-"pay-phone",
-"pedestal",
-"pencil_box",
-"pencil_sharpener",
-"perfume",
-"Petri_dish",
-"photocopier",
-"pick",
-"pickelhaube",
-"picket_fence",
-"pickup",
-"pier",
-"piggy_bank",
-"pill_bottle",
-"pillow",
-"ping-pong_ball",
-"pinwheel",
-"pirate",
-"pitcher",
-"plane",
-"planetarium",
-"plastic_bag",
-"plate_rack",
-"plow",
-"plunger",
-"Polaroid_camera",
-"pole",
-"police_van",
-"poncho",
-"pool_table",
-"pop_bottle",
-"pot",
-"potter's_wheel",
-"power_drill",
-"prayer_rug",
-"printer",
-"prison",
-"projectile",
-"projector",
-"puck",
-"punching_bag",
-"purse",
-"quill",
-"quilt",
-"racer",
-"racket",
-"radiator",
-"radio",
-"radio_telescope",
-"rain_barrel",
-"recreational_vehicle",
-"reel",
-"reflex_camera",
-"refrigerator",
-"remote_control",
-"restaurant",
-"revolver",
-"rifle",
-"rocking_chair",
-"rotisserie",
-"rubber_eraser",
-"rugby_ball",
-"rule",
-"running_shoe",
-"safe",
-"safety_pin",
-"saltshaker",
-"sandal",
-"sarong",
-"sax",
-"scabbard",
-"scale",
-"school_bus",
-"schooner",
-"scoreboard",
-"screen",
-"screw",
-"screwdriver",
-"seat_belt",
-"sewing_machine",
-"shield",
-"shoe_shop",
-"shoji",
-"shopping_basket",
-"shopping_cart",
-"shovel",
-"shower_cap",
-"shower_curtain",
-"ski",
-"ski_mask",
-"sleeping_bag",
-"slide_rule",
-"sliding_door",
-"slot",
-"snorkel",
-"snowmobile",
-"snowplow",
-"soap_dispenser",
-"soccer_ball",
-"sock",
-"solar_dish",
-"sombrero",
-"soup_bowl",
-"space_bar",
-"space_heater",
-"space_shuttle",
-"spatula",
-"speedboat",
-"spider_web",
-"spindle",
-"sports_car",
-"spotlight",
-"stage",
-"steam_locomotive",
-"steel_arch_bridge",
-"steel_drum",
-"stethoscope",
-"stole",
-"stone_wall",
-"stopwatch",
-"stove",
-"strainer",
-"streetcar",
-"stretcher",
-"studio_couch",
-"stupa",
-"submarine",
-"suit",
-"sundial",
-"sunglass",
-"sunglasses",
-"sunscreen",
-"suspension_bridge",
-"swab",
-"sweatshirt",
-"swimming_trunks",
-"swing",
-"switch",
-"syringe",
-"table_lamp",
-"tank",
-"tape_player",
-"teapot",
-"teddy",
-"television",
-"tennis_ball",
-"thatch",
-"theater_curtain",
-"thimble",
-"thresher",
-"throne",
-"tile_roof",
-"toaster",
-"tobacco_shop",
-"toilet_seat",
-"torch",
-"totem_pole",
-"tow_truck",
-"toyshop",
-"tractor",
-"trailer_truck",
-"tray",
-"trench_coat",
-"tricycle",
-"trimaran",
-"tripod",
-"triumphal_arch",
-"trolleybus",
-"trombone",
-"tub",
-"turnstile",
-"typewriter_keyboard",
-"umbrella",
-"unicycle",
-"upright",
-"vacuum",
-"vase",
-"vault",
-"velvet",
-"vending_machine",
-"vestment",
-"viaduct",
-"violin",
-"volleyball",
-"waffle_iron",
-"wall_clock",
-"wallet",
-"wardrobe",
-"warplane",
-"washbasin",
-"washer",
-"water_bottle",
-"water_jug",
-"water_tower",
-"whiskey_jug",
-"whistle",
-"wig",
-"window_screen",
-"window_shade",
-"Windsor_tie",
-"wine_bottle",
-"wing",
-"wok",
-"wooden_spoon",
-"wool",
-"worm_fence",
-"wreck",
-"yawl",
-"yurt",
-"web_site",
-"comic_book",
-"crossword_puzzle",
-"street_sign",
-"traffic_light",
-"book_jacket",
-"menu",
-"plate",
-"guacamole",
-"consomme",
-"hot_pot",
-"trifle",
-"ice_cream",
-"ice_lolly",
-"French_loaf",
-"bagel",
-"pretzel",
-"cheeseburger",
-"hotdog",
-"mashed_potato",
-"head_cabbage",
-"broccoli",
-"cauliflower",
-"zucchini",
-"spaghetti_squash",
-"acorn_squash",
-"butternut_squash",
-"cucumber",
-"artichoke",
-"bell_pepper",
-"cardoon",
-"mushroom",
-"Granny_Smith",
-"strawberry",
-"orange",
-"lemon",
-"fig",
-"pineapple",
-"banana",
-"jackfruit",
-"custard_apple",
-"pomegranate",
-"hay",
-"carbonara",
-"chocolate_sauce",
-"dough",
-"meat_loaf",
-"pizza",
-"potpie",
-"burrito",
-"red_wine",
-"espresso",
-"cup",
-"eggnog",
-"alp",
-"bubble",
-"cliff",
-"coral_reef",
-"geyser",
-"lakeside",
-"promontory",
-"sandbar",
-"seashore",
-"valley",
-"volcano",
-"ballplayer",
-"groom",
-"scuba_diver",
-"rapeseed",
-"daisy",
-"yellow_lady's_slipper",
-"corn",
-"acorn",
-"hip",
-"buckeye",
-"coral_fungus",
-"agaric",
-"gyromitra",
-"stinkhorn",
-"earthstar",
-"hen-of-the-woods",
-"bolete",
-"ear",
-"toilet_tissue"
-};
diff --git a/examples/imagenet/imagenet_classes.h b/examples/imagenet/imagenet_classes.h
deleted file mode 100644 (file)
index b6a3463..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
- *   All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions are met:
- *       * Redistributions of source code must retain the above copyright
- *         notice, this list of conditions and the following disclaimer.
- *       * Redistributions in binary form must reproduce the above copyright
- *         notice, this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *       * Neither the name of Texas Instruments Incorporated nor the
- *         names of its contributors may be used to endorse or promote products
- *         derived from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- *   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- *   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- *   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- *   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- *   THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
-#ifndef _IMAGENET_CLASSES_H_
-#define _IMAGENET_CLASSES_H_
-
-#include <string>
-
-#define NUM_IMAGENET_CLASSES  1000
-
-extern std::string imagenet_classes[NUM_IMAGENET_CLASSES];
-
-#endif
diff --git a/examples/imagenet/imagenet_objects.json b/examples/imagenet/imagenet_objects.json
new file mode 100644 (file)
index 0000000..7a5289b
--- /dev/null
@@ -0,0 +1,1005 @@
+{
+  "network": "imagenet",
+  "objects": [
+    { "label": "tench" },
+    { "label": "goldfish" },
+    { "label": "great_white_shark" },
+    { "label": "tiger_shark" },
+    { "label": "hammerhead" },
+    { "label": "electric_ray" },
+    { "label": "stingray" },
+    { "label": "cock" },
+    { "label": "hen" },
+    { "label": "ostrich" },
+    { "label": "brambling" },
+    { "label": "goldfinch" },
+    { "label": "house_finch" },
+    { "label": "junco" },
+    { "label": "indigo_bunting" },
+    { "label": "robin" },
+    { "label": "bulbul" },
+    { "label": "jay" },
+    { "label": "magpie" },
+    { "label": "chickadee" },
+    { "label": "water_ouzel" },
+    { "label": "kite" },
+    { "label": "bald_eagle" },
+    { "label": "vulture" },
+    { "label": "great_grey_owl" },
+    { "label": "European_fire_salamander" },
+    { "label": "common_newt" },
+    { "label": "eft" },
+    { "label": "spotted_salamander" },
+    { "label": "axolotl" },
+    { "label": "bullfrog" },
+    { "label": "tree_frog" },
+    { "label": "tailed_frog" },
+    { "label": "loggerhead" },
+    { "label": "leatherback_turtle" },
+    { "label": "mud_turtle" },
+    { "label": "terrapin" },
+    { "label": "box_turtle" },
+    { "label": "banded_gecko" },
+    { "label": "common_iguana" },
+    { "label": "American_chameleon" },
+    { "label": "whiptail" },
+    { "label": "agama" },
+    { "label": "frilled_lizard" },
+    { "label": "alligator_lizard" },
+    { "label": "Gila_monster" },
+    { "label": "green_lizard" },
+    { "label": "African_chameleon" },
+    { "label": "Komodo_dragon" },
+    { "label": "African_crocodile" },
+    { "label": "American_alligator" },
+    { "label": "triceratops" },
+    { "label": "thunder_snake" },
+    { "label": "ringneck_snake" },
+    { "label": "hognose_snake" },
+    { "label": "green_snake" },
+    { "label": "king_snake" },
+    { "label": "garter_snake" },
+    { "label": "water_snake" },
+    { "label": "vine_snake" },
+    { "label": "night_snake" },
+    { "label": "boa_constrictor" },
+    { "label": "rock_python" },
+    { "label": "Indian_cobra" },
+    { "label": "green_mamba" },
+    { "label": "sea_snake" },
+    { "label": "horned_viper" },
+    { "label": "diamondback" },
+    { "label": "sidewinder" },
+    { "label": "trilobite" },
+    { "label": "harvestman" },
+    { "label": "scorpion" },
+    { "label": "black_and_gold_garden_spider" },
+    { "label": "barn_spider" },
+    { "label": "garden_spider" },
+    { "label": "black_widow" },
+    { "label": "tarantula" },
+    { "label": "wolf_spider" },
+    { "label": "tick" },
+    { "label": "centipede" },
+    { "label": "black_grouse" },
+    { "label": "ptarmigan" },
+    { "label": "ruffed_grouse" },
+    { "label": "prairie_chicken" },
+    { "label": "peacock" },
+    { "label": "quail" },
+    { "label": "partridge" },
+    { "label": "African_grey" },
+    { "label": "macaw" },
+    { "label": "sulphur-crested_cockatoo" },
+    { "label": "lorikeet" },
+    { "label": "coucal" },
+    { "label": "bee_eater" },
+    { "label": "hornbill" },
+    { "label": "hummingbird" },
+    { "label": "jacamar" },
+    { "label": "toucan" },
+    { "label": "drake" },
+    { "label": "red-breasted_merganser" },
+    { "label": "goose" },
+    { "label": "black_swan" },
+    { "label": "tusker" },
+    { "label": "echidna" },
+    { "label": "platypus" },
+    { "label": "wallaby" },
+    { "label": "koala" },
+    { "label": "wombat" },
+    { "label": "jellyfish" },
+    { "label": "sea_anemone" },
+    { "label": "brain_coral" },
+    { "label": "flatworm" },
+    { "label": "nematode" },
+    { "label": "conch" },
+    { "label": "snail" },
+    { "label": "slug" },
+    { "label": "sea_slug" },
+    { "label": "chiton" },
+    { "label": "chambered_nautilus" },
+    { "label": "Dungeness_crab" },
+    { "label": "rock_crab" },
+    { "label": "fiddler_crab" },
+    { "label": "king_crab" },
+    { "label": "American_lobster" },
+    { "label": "spiny_lobster" },
+    { "label": "crayfish" },
+    { "label": "hermit_crab" },
+    { "label": "isopod" },
+    { "label": "white_stork" },
+    { "label": "black_stork" },
+    { "label": "spoonbill" },
+    { "label": "flamingo" },
+    { "label": "little_blue_heron" },
+    { "label": "American_egret" },
+    { "label": "bittern" },
+    { "label": "crane" },
+    { "label": "limpkin" },
+    { "label": "European_gallinule" },
+    { "label": "American_coot" },
+    { "label": "bustard" },
+    { "label": "ruddy_turnstone" },
+    { "label": "red-backed_sandpiper" },
+    { "label": "redshank" },
+    { "label": "dowitcher" },
+    { "label": "oystercatcher" },
+    { "label": "pelican" },
+    { "label": "king_penguin" },
+    { "label": "albatross" },
+    { "label": "grey_whale" },
+    { "label": "killer_whale" },
+    { "label": "dugong" },
+    { "label": "sea_lion" },
+    { "label": "Chihuahua" },
+    { "label": "Japanese_spaniel" },
+    { "label": "Maltese_dog" },
+    { "label": "Pekinese" },
+    { "label": "Shih-Tzu" },
+    { "label": "Blenheim_spaniel" },
+    { "label": "papillon" },
+    { "label": "toy_terrier" },
+    { "label": "Rhodesian_ridgeback" },
+    { "label": "Afghan_hound" },
+    { "label": "basset" },
+    { "label": "beagle" },
+    { "label": "bloodhound" },
+    { "label": "bluetick" },
+    { "label": "black-and-tan_coonhound" },
+    { "label": "Walker_hound" },
+    { "label": "English_foxhound" },
+    { "label": "redbone" },
+    { "label": "borzoi" },
+    { "label": "Irish_wolfhound" },
+    { "label": "Italian_greyhound" },
+    { "label": "whippet" },
+    { "label": "Ibizan_hound" },
+    { "label": "Norwegian_elkhound" },
+    { "label": "otterhound" },
+    { "label": "Saluki" },
+    { "label": "Scottish_deerhound" },
+    { "label": "Weimaraner" },
+    { "label": "Staffordshire_bullterrier" },
+    { "label": "American_Staffordshire_terrier" },
+    { "label": "Bedlington_terrier" },
+    { "label": "Border_terrier" },
+    { "label": "Kerry_blue_terrier" },
+    { "label": "Irish_terrier" },
+    { "label": "Norfolk_terrier" },
+    { "label": "Norwich_terrier" },
+    { "label": "Yorkshire_terrier" },
+    { "label": "wire-haired_fox_terrier" },
+    { "label": "Lakeland_terrier" },
+    { "label": "Sealyham_terrier" },
+    { "label": "Airedale" },
+    { "label": "cairn" },
+    { "label": "Australian_terrier" },
+    { "label": "Dandie_Dinmont" },
+    { "label": "Boston_bull" },
+    { "label": "miniature_schnauzer" },
+    { "label": "giant_schnauzer" },
+    { "label": "standard_schnauzer" },
+    { "label": "Scotch_terrier" },
+    { "label": "Tibetan_terrier" },
+    { "label": "silky_terrier" },
+    { "label": "soft-coated_wheaten_terrier" },
+    { "label": "West_Highland_white_terrier" },
+    { "label": "Lhasa" },
+    { "label": "flat-coated_retriever" },
+    { "label": "curly-coated_retriever" },
+    { "label": "golden_retriever" },
+    { "label": "Labrador_retriever" },
+    { "label": "Chesapeake_Bay_retriever" },
+    { "label": "German_short-haired_pointer" },
+    { "label": "vizsla" },
+    { "label": "English_setter" },
+    { "label": "Irish_setter" },
+    { "label": "Gordon_setter" },
+    { "label": "Brittany_spaniel" },
+    { "label": "clumber" },
+    { "label": "English_springer" },
+    { "label": "Welsh_springer_spaniel" },
+    { "label": "cocker_spaniel" },
+    { "label": "Sussex_spaniel" },
+    { "label": "Irish_water_spaniel" },
+    { "label": "kuvasz" },
+    { "label": "schipperke" },
+    { "label": "groenendael" },
+    { "label": "malinois" },
+    { "label": "briard" },
+    { "label": "kelpie" },
+    { "label": "komondor" },
+    { "label": "Old_English_sheepdog" },
+    { "label": "Shetland_sheepdog" },
+    { "label": "collie" },
+    { "label": "Border_collie" },
+    { "label": "Bouvier_des_Flandres" },
+    { "label": "Rottweiler" },
+    { "label": "German_shepherd" },
+    { "label": "Doberman" },
+    { "label": "miniature_pinscher" },
+    { "label": "Greater_Swiss_Mountain_dog" },
+    { "label": "Bernese_mountain_dog" },
+    { "label": "Appenzeller" },
+    { "label": "EntleBucher" },
+    { "label": "boxer" },
+    { "label": "bull_mastiff" },
+    { "label": "Tibetan_mastiff" },
+    { "label": "French_bulldog" },
+    { "label": "Great_Dane" },
+    { "label": "Saint_Bernard" },
+    { "label": "Eskimo_dog" },
+    { "label": "malamute" },
+    { "label": "Siberian_husky" },
+    { "label": "dalmatian" },
+    { "label": "affenpinscher" },
+    { "label": "basenji" },
+    { "label": "pug" },
+    { "label": "Leonberg" },
+    { "label": "Newfoundland" },
+    { "label": "Great_Pyrenees" },
+    { "label": "Samoyed" },
+    { "label": "Pomeranian" },
+    { "label": "chow" },
+    { "label": "keeshond" },
+    { "label": "Brabancon_griffon" },
+    { "label": "Pembroke" },
+    { "label": "Cardigan" },
+    { "label": "toy_poodle" },
+    { "label": "miniature_poodle" },
+    { "label": "standard_poodle" },
+    { "label": "Mexican_hairless" },
+    { "label": "timber_wolf" },
+    { "label": "white_wolf" },
+    { "label": "red_wolf" },
+    { "label": "coyote" },
+    { "label": "dingo" },
+    { "label": "dhole" },
+    { "label": "African_hunting_dog" },
+    { "label": "hyena" },
+    { "label": "red_fox" },
+    { "label": "kit_fox" },
+    { "label": "Arctic_fox" },
+    { "label": "grey_fox" },
+    { "label": "tabby" },
+    { "label": "tiger_cat" },
+    { "label": "Persian_cat" },
+    { "label": "Siamese_cat" },
+    { "label": "Egyptian_cat" },
+    { "label": "cougar" },
+    { "label": "lynx" },
+    { "label": "leopard" },
+    { "label": "snow_leopard" },
+    { "label": "jaguar" },
+    { "label": "lion" },
+    { "label": "tiger" },
+    { "label": "cheetah" },
+    { "label": "brown_bear" },
+    { "label": "American_black_bear" },
+    { "label": "ice_bear" },
+    { "label": "sloth_bear" },
+    { "label": "mongoose" },
+    { "label": "meerkat" },
+    { "label": "tiger_beetle" },
+    { "label": "ladybug" },
+    { "label": "ground_beetle" },
+    { "label": "long-horned_beetle" },
+    { "label": "leaf_beetle" },
+    { "label": "dung_beetle" },
+    { "label": "rhinoceros_beetle" },
+    { "label": "weevil" },
+    { "label": "fly" },
+    { "label": "bee" },
+    { "label": "ant" },
+    { "label": "grasshopper" },
+    { "label": "cricket" },
+    { "label": "walking_stick" },
+    { "label": "cockroach" },
+    { "label": "mantis" },
+    { "label": "cicada" },
+    { "label": "leafhopper" },
+    { "label": "lacewing" },
+    { "label": "dragonfly" },
+    { "label": "damselfly" },
+    { "label": "admiral" },
+    { "label": "ringlet" },
+    { "label": "monarch" },
+    { "label": "cabbage_butterfly" },
+    { "label": "sulphur_butterfly" },
+    { "label": "lycaenid" },
+    { "label": "starfish" },
+    { "label": "sea_urchin" },
+    { "label": "sea_cucumber" },
+    { "label": "wood_rabbit" },
+    { "label": "hare" },
+    { "label": "Angora" },
+    { "label": "hamster" },
+    { "label": "porcupine" },
+    { "label": "fox_squirrel" },
+    { "label": "marmot" },
+    { "label": "beaver" },
+    { "label": "guinea_pig" },
+    { "label": "sorrel" },
+    { "label": "zebra" },
+    { "label": "hog" },
+    { "label": "wild_boar" },
+    { "label": "warthog" },
+    { "label": "hippopotamus" },
+    { "label": "ox" },
+    { "label": "water_buffalo" },
+    { "label": "bison" },
+    { "label": "ram" },
+    { "label": "bighorn" },
+    { "label": "ibex" },
+    { "label": "hartebeest" },
+    { "label": "impala" },
+    { "label": "gazelle" },
+    { "label": "Arabian_camel" },
+    { "label": "llama" },
+    { "label": "weasel" },
+    { "label": "mink" },
+    { "label": "polecat" },
+    { "label": "black-footed_ferret" },
+    { "label": "otter" },
+    { "label": "skunk" },
+    { "label": "badger" },
+    { "label": "armadillo" },
+    { "label": "three-toed_sloth" },
+    { "label": "orangutan" },
+    { "label": "gorilla" },
+    { "label": "chimpanzee" },
+    { "label": "gibbon" },
+    { "label": "siamang" },
+    { "label": "guenon" },
+    { "label": "patas" },
+    { "label": "baboon" },
+    { "label": "macaque" },
+    { "label": "langur" },
+    { "label": "colobus" },
+    { "label": "proboscis_monkey" },
+    { "label": "marmoset" },
+    { "label": "capuchin" },
+    { "label": "howler_monkey" },
+    { "label": "titi" },
+    { "label": "spider_monkey" },
+    { "label": "squirrel_monkey" },
+    { "label": "Madagascar_cat" },
+    { "label": "indri" },
+    { "label": "Indian_elephant" },
+    { "label": "African_elephant" },
+    { "label": "lesser_panda" },
+    { "label": "giant_panda" },
+    { "label": "barracouta" },
+    { "label": "eel" },
+    { "label": "coho" },
+    { "label": "rock_beauty" },
+    { "label": "anemone_fish" },
+    { "label": "sturgeon" },
+    { "label": "gar" },
+    { "label": "lionfish" },
+    { "label": "puffer" },
+    { "label": "abacus" },
+    { "label": "abaya" },
+    { "label": "academic_gown" },
+    { "label": "accordion" },
+    { "label": "acoustic_guitar" },
+    { "label": "aircraft_carrier" },
+    { "label": "airliner" },
+    { "label": "airship" },
+    { "label": "altar" },
+    { "label": "ambulance" },
+    { "label": "amphibian" },
+    { "label": "analog_clock" },
+    { "label": "apiary" },
+    { "label": "apron" },
+    { "label": "ashcan" },
+    { "label": "assault_rifle" },
+    { "label": "backpack" },
+    { "label": "bakery" },
+    { "label": "balance_beam" },
+    { "label": "balloon" },
+    { "label": "ballpoint" },
+    { "label": "Band_Aid" },
+    { "label": "banjo" },
+    { "label": "bannister" },
+    { "label": "barbell" },
+    { "label": "barber_chair" },
+    { "label": "barbershop" },
+    { "label": "barn" },
+    { "label": "barometer" },
+    { "label": "barrel" },
+    { "label": "barrow" },
+    { "label": "baseball" },
+    { "label": "basketball" },
+    { "label": "bassinet" },
+    { "label": "bassoon" },
+    { "label": "bathing_cap" },
+    { "label": "bath_towel" },
+    { "label": "bathtub" },
+    { "label": "beach_wagon" },
+    { "label": "beacon" },
+    { "label": "beaker" },
+    { "label": "bearskin" },
+    { "label": "beer_bottle" },
+    { "label": "beer_glass" },
+    { "label": "bell_cote" },
+    { "label": "bib" },
+    { "label": "bicycle-built-for-two" },
+    { "label": "bikini" },
+    { "label": "binder" },
+    { "label": "binoculars" },
+    { "label": "birdhouse" },
+    { "label": "boathouse" },
+    { "label": "bobsled" },
+    { "label": "bolo_tie" },
+    { "label": "bonnet" },
+    { "label": "bookcase" },
+    { "label": "bookshop" },
+    { "label": "bottlecap" },
+    { "label": "bow" },
+    { "label": "bow_tie" },
+    { "label": "brass" },
+    { "label": "brassiere" },
+    { "label": "breakwater" },
+    { "label": "breastplate" },
+    { "label": "broom" },
+    { "label": "bucket" },
+    { "label": "buckle" },
+    { "label": "bulletproof_vest" },
+    { "label": "bullet_train" },
+    { "label": "butcher_shop" },
+    { "label": "cab" },
+    { "label": "caldron" },
+    { "label": "candle" },
+    { "label": "cannon" },
+    { "label": "canoe" },
+    { "label": "can_opener" },
+    { "label": "cardigan" },
+    { "label": "car_mirror" },
+    { "label": "carousel" },
+    { "label": "carpenter's_kit" },
+    { "label": "carton" },
+    { "label": "car_wheel" },
+    { "label": "cash_machine" },
+    { "label": "cassette" },
+    { "label": "cassette_player" },
+    { "label": "castle" },
+    { "label": "catamaran" },
+    { "label": "CD_player" },
+    { "label": "cello" },
+    { "label": "cellular_telephone" },
+    { "label": "chain" },
+    { "label": "chainlink_fence" },
+    { "label": "chain_mail" },
+    { "label": "chain_saw" },
+    { "label": "chest" },
+    { "label": "chiffonier" },
+    { "label": "chime" },
+    { "label": "china_cabinet" },
+    { "label": "Christmas_stocking" },
+    { "label": "church" },
+    { "label": "cinema" },
+    { "label": "cleaver" },
+    { "label": "cliff_dwelling" },
+    { "label": "cloak" },
+    { "label": "clog" },
+    { "label": "cocktail_shaker" },
+    { "label": "coffee_mug" },
+    { "label": "coffeepot" },
+    { "label": "coil" },
+    { "label": "combination_lock" },
+    { "label": "computer_keyboard" },
+    { "label": "confectionery" },
+    { "label": "container_ship" },
+    { "label": "convertible" },
+    { "label": "corkscrew" },
+    { "label": "cornet" },
+    { "label": "cowboy_boot" },
+    { "label": "cowboy_hat" },
+    { "label": "cradle" },
+    { "label": "crane" },
+    { "label": "crash_helmet" },
+    { "label": "crate" },
+    { "label": "crib" },
+    { "label": "Crock_Pot" },
+    { "label": "croquet_ball" },
+    { "label": "crutch" },
+    { "label": "cuirass" },
+    { "label": "dam" },
+    { "label": "desk" },
+    { "label": "desktop_computer" },
+    { "label": "dial_telephone" },
+    { "label": "diaper" },
+    { "label": "digital_clock" },
+    { "label": "digital_watch" },
+    { "label": "dining_table" },
+    { "label": "dishrag" },
+    { "label": "dishwasher" },
+    { "label": "disk_brake" },
+    { "label": "dock" },
+    { "label": "dogsled" },
+    { "label": "dome" },
+    { "label": "doormat" },
+    { "label": "drilling_platform" },
+    { "label": "drum" },
+    { "label": "drumstick" },
+    { "label": "dumbbell" },
+    { "label": "Dutch_oven" },
+    { "label": "electric_fan" },
+    { "label": "electric_guitar" },
+    { "label": "electric_locomotive" },
+    { "label": "entertainment_center" },
+    { "label": "envelope" },
+    { "label": "espresso_maker" },
+    { "label": "face_powder" },
+    { "label": "feather_boa" },
+    { "label": "file" },
+    { "label": "fireboat" },
+    { "label": "fire_engine" },
+    { "label": "fire_screen" },
+    { "label": "flagpole" },
+    { "label": "flute" },
+    { "label": "folding_chair" },
+    { "label": "football_helmet" },
+    { "label": "forklift" },
+    { "label": "fountain" },
+    { "label": "fountain_pen" },
+    { "label": "four-poster" },
+    { "label": "freight_car" },
+    { "label": "French_horn" },
+    { "label": "frying_pan" },
+    { "label": "fur_coat" },
+    { "label": "garbage_truck" },
+    { "label": "gasmask" },
+    { "label": "gas_pump" },
+    { "label": "goblet" },
+    { "label": "go-kart" },
+    { "label": "golf_ball" },
+    { "label": "golfcart" },
+    { "label": "gondola" },
+    { "label": "gong" },
+    { "label": "gown" },
+    { "label": "grand_piano" },
+    { "label": "greenhouse" },
+    { "label": "grille" },
+    { "label": "grocery_store" },
+    { "label": "guillotine" },
+    { "label": "hair_slide" },
+    { "label": "hair_spray" },
+    { "label": "half_track" },
+    { "label": "hammer" },
+    { "label": "hamper" },
+    { "label": "hand_blower" },
+    { "label": "hand-held_computer" },
+    { "label": "handkerchief" },
+    { "label": "hard_disc" },
+    { "label": "harmonica" },
+    { "label": "harp" },
+    { "label": "harvester" },
+    { "label": "hatchet" },
+    { "label": "holster" },
+    { "label": "home_theater" },
+    { "label": "honeycomb" },
+    { "label": "hook" },
+    { "label": "hoopskirt" },
+    { "label": "horizontal_bar" },
+    { "label": "horse_cart" },
+    { "label": "hourglass" },
+    { "label": "iPod" },
+    { "label": "iron" },
+    { "label": "jack-o'-lantern" },
+    { "label": "jean" },
+    { "label": "jeep" },
+    { "label": "jersey" },
+    { "label": "jigsaw_puzzle" },
+    { "label": "jinrikisha" },
+    { "label": "joystick" },
+    { "label": "kimono" },
+    { "label": "knee_pad" },
+    { "label": "knot" },
+    { "label": "lab_coat" },
+    { "label": "ladle" },
+    { "label": "lampshade" },
+    { "label": "laptop" },
+    { "label": "lawn_mower" },
+    { "label": "lens_cap" },
+    { "label": "letter_opener" },
+    { "label": "library" },
+    { "label": "lifeboat" },
+    { "label": "lighter" },
+    { "label": "limousine" },
+    { "label": "liner" },
+    { "label": "lipstick" },
+    { "label": "Loafer" },
+    { "label": "lotion" },
+    { "label": "loudspeaker" },
+    { "label": "loupe" },
+    { "label": "lumbermill" },
+    { "label": "magnetic_compass" },
+    { "label": "mailbag" },
+    { "label": "mailbox" },
+    { "label": "maillot" },
+    { "label": "maillot" },
+    { "label": "manhole_cover" },
+    { "label": "maraca" },
+    { "label": "marimba" },
+    { "label": "mask" },
+    { "label": "matchstick" },
+    { "label": "maypole" },
+    { "label": "maze" },
+    { "label": "measuring_cup" },
+    { "label": "medicine_chest" },
+    { "label": "megalith" },
+    { "label": "microphone" },
+    { "label": "microwave" },
+    { "label": "military_uniform" },
+    { "label": "milk_can" },
+    { "label": "minibus" },
+    { "label": "miniskirt" },
+    { "label": "minivan" },
+    { "label": "missile" },
+    { "label": "mitten" },
+    { "label": "mixing_bowl" },
+    { "label": "mobile_home" },
+    { "label": "Model_T" },
+    { "label": "modem" },
+    { "label": "monastery" },
+    { "label": "monitor" },
+    { "label": "moped" },
+    { "label": "mortar" },
+    { "label": "mortarboard" },
+    { "label": "mosque" },
+    { "label": "mosquito_net" },
+    { "label": "motor_scooter" },
+    { "label": "mountain_bike" },
+    { "label": "mountain_tent" },
+    { "label": "mouse" },
+    { "label": "mousetrap" },
+    { "label": "moving_van" },
+    { "label": "muzzle" },
+    { "label": "nail" },
+    { "label": "neck_brace" },
+    { "label": "necklace" },
+    { "label": "nipple" },
+    { "label": "notebook" },
+    { "label": "obelisk" },
+    { "label": "oboe" },
+    { "label": "ocarina" },
+    { "label": "odometer" },
+    { "label": "oil_filter" },
+    { "label": "organ" },
+    { "label": "oscilloscope" },
+    { "label": "overskirt" },
+    { "label": "oxcart" },
+    { "label": "oxygen_mask" },
+    { "label": "packet" },
+    { "label": "paddle" },
+    { "label": "paddlewheel" },
+    { "label": "padlock" },
+    { "label": "paintbrush" },
+    { "label": "pajama" },
+    { "label": "palace" },
+    { "label": "panpipe" },
+    { "label": "paper_towel" },
+    { "label": "parachute" },
+    { "label": "parallel_bars" },
+    { "label": "park_bench" },
+    { "label": "parking_meter" },
+    { "label": "passenger_car" },
+    { "label": "patio" },
+    { "label": "pay-phone" },
+    { "label": "pedestal" },
+    { "label": "pencil_box" },
+    { "label": "pencil_sharpener" },
+    { "label": "perfume" },
+    { "label": "Petri_dish" },
+    { "label": "photocopier" },
+    { "label": "pick" },
+    { "label": "pickelhaube" },
+    { "label": "picket_fence" },
+    { "label": "pickup" },
+    { "label": "pier" },
+    { "label": "piggy_bank" },
+    { "label": "pill_bottle" },
+    { "label": "pillow" },
+    { "label": "ping-pong_ball" },
+    { "label": "pinwheel" },
+    { "label": "pirate" },
+    { "label": "pitcher" },
+    { "label": "plane" },
+    { "label": "planetarium" },
+    { "label": "plastic_bag" },
+    { "label": "plate_rack" },
+    { "label": "plow" },
+    { "label": "plunger" },
+    { "label": "Polaroid_camera" },
+    { "label": "pole" },
+    { "label": "police_van" },
+    { "label": "poncho" },
+    { "label": "pool_table" },
+    { "label": "pop_bottle" },
+    { "label": "pot" },
+    { "label": "potter's_wheel" },
+    { "label": "power_drill" },
+    { "label": "prayer_rug" },
+    { "label": "printer" },
+    { "label": "prison" },
+    { "label": "projectile" },
+    { "label": "projector" },
+    { "label": "puck" },
+    { "label": "punching_bag" },
+    { "label": "purse" },
+    { "label": "quill" },
+    { "label": "quilt" },
+    { "label": "racer" },
+    { "label": "racket" },
+    { "label": "radiator" },
+    { "label": "radio" },
+    { "label": "radio_telescope" },
+    { "label": "rain_barrel" },
+    { "label": "recreational_vehicle" },
+    { "label": "reel" },
+    { "label": "reflex_camera" },
+    { "label": "refrigerator" },
+    { "label": "remote_control" },
+    { "label": "restaurant" },
+    { "label": "revolver" },
+    { "label": "rifle" },
+    { "label": "rocking_chair" },
+    { "label": "rotisserie" },
+    { "label": "rubber_eraser" },
+    { "label": "rugby_ball" },
+    { "label": "rule" },
+    { "label": "running_shoe" },
+    { "label": "safe" },
+    { "label": "safety_pin" },
+    { "label": "saltshaker" },
+    { "label": "sandal" },
+    { "label": "sarong" },
+    { "label": "sax" },
+    { "label": "scabbard" },
+    { "label": "scale" },
+    { "label": "school_bus" },
+    { "label": "schooner" },
+    { "label": "scoreboard" },
+    { "label": "screen" },
+    { "label": "screw" },
+    { "label": "screwdriver" },
+    { "label": "seat_belt" },
+    { "label": "sewing_machine" },
+    { "label": "shield" },
+    { "label": "shoe_shop" },
+    { "label": "shoji" },
+    { "label": "shopping_basket" },
+    { "label": "shopping_cart" },
+    { "label": "shovel" },
+    { "label": "shower_cap" },
+    { "label": "shower_curtain" },
+    { "label": "ski" },
+    { "label": "ski_mask" },
+    { "label": "sleeping_bag" },
+    { "label": "slide_rule" },
+    { "label": "sliding_door" },
+    { "label": "slot" },
+    { "label": "snorkel" },
+    { "label": "snowmobile" },
+    { "label": "snowplow" },
+    { "label": "soap_dispenser" },
+    { "label": "soccer_ball" },
+    { "label": "sock" },
+    { "label": "solar_dish" },
+    { "label": "sombrero" },
+    { "label": "soup_bowl" },
+    { "label": "space_bar" },
+    { "label": "space_heater" },
+    { "label": "space_shuttle" },
+    { "label": "spatula" },
+    { "label": "speedboat" },
+    { "label": "spider_web" },
+    { "label": "spindle" },
+    { "label": "sports_car" },
+    { "label": "spotlight" },
+    { "label": "stage" },
+    { "label": "steam_locomotive" },
+    { "label": "steel_arch_bridge" },
+    { "label": "steel_drum" },
+    { "label": "stethoscope" },
+    { "label": "stole" },
+    { "label": "stone_wall" },
+    { "label": "stopwatch" },
+    { "label": "stove" },
+    { "label": "strainer" },
+    { "label": "streetcar" },
+    { "label": "stretcher" },
+    { "label": "studio_couch" },
+    { "label": "stupa" },
+    { "label": "submarine" },
+    { "label": "suit" },
+    { "label": "sundial" },
+    { "label": "sunglass" },
+    { "label": "sunglasses" },
+    { "label": "sunscreen" },
+    { "label": "suspension_bridge" },
+    { "label": "swab" },
+    { "label": "sweatshirt" },
+    { "label": "swimming_trunks" },
+    { "label": "swing" },
+    { "label": "switch" },
+    { "label": "syringe" },
+    { "label": "table_lamp" },
+    { "label": "tank" },
+    { "label": "tape_player" },
+    { "label": "teapot" },
+    { "label": "teddy" },
+    { "label": "television" },
+    { "label": "tennis_ball" },
+    { "label": "thatch" },
+    { "label": "theater_curtain" },
+    { "label": "thimble" },
+    { "label": "thresher" },
+    { "label": "throne" },
+    { "label": "tile_roof" },
+    { "label": "toaster" },
+    { "label": "tobacco_shop" },
+    { "label": "toilet_seat" },
+    { "label": "torch" },
+    { "label": "totem_pole" },
+    { "label": "tow_truck" },
+    { "label": "toyshop" },
+    { "label": "tractor" },
+    { "label": "trailer_truck" },
+    { "label": "tray" },
+    { "label": "trench_coat" },
+    { "label": "tricycle" },
+    { "label": "trimaran" },
+    { "label": "tripod" },
+    { "label": "triumphal_arch" },
+    { "label": "trolleybus" },
+    { "label": "trombone" },
+    { "label": "tub" },
+    { "label": "turnstile" },
+    { "label": "typewriter_keyboard" },
+    { "label": "umbrella" },
+    { "label": "unicycle" },
+    { "label": "upright" },
+    { "label": "vacuum" },
+    { "label": "vase" },
+    { "label": "vault" },
+    { "label": "velvet" },
+    { "label": "vending_machine" },
+    { "label": "vestment" },
+    { "label": "viaduct" },
+    { "label": "violin" },
+    { "label": "volleyball" },
+    { "label": "waffle_iron" },
+    { "label": "wall_clock" },
+    { "label": "wallet" },
+    { "label": "wardrobe" },
+    { "label": "warplane" },
+    { "label": "washbasin" },
+    { "label": "washer" },
+    { "label": "water_bottle" },
+    { "label": "water_jug" },
+    { "label": "water_tower" },
+    { "label": "whiskey_jug" },
+    { "label": "whistle" },
+    { "label": "wig" },
+    { "label": "window_screen" },
+    { "label": "window_shade" },
+    { "label": "Windsor_tie" },
+    { "label": "wine_bottle" },
+    { "label": "wing" },
+    { "label": "wok" },
+    { "label": "wooden_spoon" },
+    { "label": "wool" },
+    { "label": "worm_fence" },
+    { "label": "wreck" },
+    { "label": "yawl" },
+    { "label": "yurt" },
+    { "label": "web_site" },
+    { "label": "comic_book" },
+    { "label": "crossword_puzzle" },
+    { "label": "street_sign" },
+    { "label": "traffic_light" },
+    { "label": "book_jacket" },
+    { "label": "menu" },
+    { "label": "plate" },
+    { "label": "guacamole" },
+    { "label": "consomme" },
+    { "label": "hot_pot" },
+    { "label": "trifle" },
+    { "label": "ice_cream" },
+    { "label": "ice_lolly" },
+    { "label": "French_loaf" },
+    { "label": "bagel" },
+    { "label": "pretzel" },
+    { "label": "cheeseburger" },
+    { "label": "hotdog" },
+    { "label": "mashed_potato" },
+    { "label": "head_cabbage" },
+    { "label": "broccoli" },
+    { "label": "cauliflower" },
+    { "label": "zucchini" },
+    { "label": "spaghetti_squash" },
+    { "label": "acorn_squash" },
+    { "label": "butternut_squash" },
+    { "label": "cucumber" },
+    { "label": "artichoke" },
+    { "label": "bell_pepper" },
+    { "label": "cardoon" },
+    { "label": "mushroom" },
+    { "label": "Granny_Smith" },
+    { "label": "strawberry" },
+    { "label": "orange" },
+    { "label": "lemon" },
+    { "label": "fig" },
+    { "label": "pineapple" },
+    { "label": "banana" },
+    { "label": "jackfruit" },
+    { "label": "custard_apple" },
+    { "label": "pomegranate" },
+    { "label": "hay" },
+    { "label": "carbonara" },
+    { "label": "chocolate_sauce" },
+    { "label": "dough" },
+    { "label": "meat_loaf" },
+    { "label": "pizza" },
+    { "label": "potpie" },
+    { "label": "burrito" },
+    { "label": "red_wine" },
+    { "label": "espresso" },
+    { "label": "cup" },
+    { "label": "eggnog" },
+    { "label": "alp" },
+    { "label": "bubble" },
+    { "label": "cliff" },
+    { "label": "coral_reef" },
+    { "label": "geyser" },
+    { "label": "lakeside" },
+    { "label": "promontory" },
+    { "label": "sandbar" },
+    { "label": "seashore" },
+    { "label": "valley" },
+    { "label": "volcano" },
+    { "label": "ballplayer" },
+    { "label": "groom" },
+    { "label": "scuba_diver" },
+    { "label": "rapeseed" },
+    { "label": "daisy" },
+    { "label": "yellow_lady's_slipper" },
+    { "label": "corn" },
+    { "label": "acorn" },
+    { "label": "hip" },
+    { "label": "buckeye" },
+    { "label": "coral_fungus" },
+    { "label": "agaric" },
+    { "label": "gyromitra" },
+    { "label": "stinkhorn" },
+    { "label": "earthstar" },
+    { "label": "hen-of-the-woods" },
+    { "label": "bolete" },
+    { "label": "ear" },
+    { "label": "toilet_tissue" }
+  ]
+}
index 149f759ad50befebb136bf501490cb1cc0c9fb51..89c203ee93f37f2588cd492c4a7f3c6fa4a720cc 100644 (file)
@@ -44,7 +44,7 @@
 #include "execution_object.h"
 #include "execution_object_pipeline.h"
 #include "configuration.h"
-#include "imagenet_classes.h"
+#include "../common/object_classes.h"
 #include "imgutil.h"
 #include "../common/video_utils.h"
 
@@ -60,10 +60,13 @@ using namespace cv;
 #define NUM_VIDEO_FRAMES  300
 #define DEFAULT_CONFIG    "j11_v2"
 #define NUM_DEFAULT_INPUTS  1
+#define DEFAULT_OBJECT_CLASSES_LIST_FILE "imagenet_objects.json"
 const char *default_inputs[NUM_DEFAULT_INPUTS] =
 {
     "../test/testvecs/input/objects/cat-pet-animal-domestic-104827.jpeg"
 };
+std::unique_ptr<ObjectClasses> object_classes;
+
 
 Executor* CreateExecutor(DeviceType dt, uint32_t num, const Configuration& c);
 bool RunConfiguration(cmdline_opts_t& opts);
@@ -92,6 +95,7 @@ int main(int argc, char *argv[])
     // Process arguments
     cmdline_opts_t opts;
     opts.config = DEFAULT_CONFIG;
+    opts.object_classes_list_file = DEFAULT_OBJECT_CLASSES_LIST_FILE;
     if (num_eves != 0) { opts.num_eves = 1;  opts.num_dsps = 0; }
     else               { opts.num_eves = 0;  opts.num_dsps = 1; }
     if (! ProcessArgs(argc, argv, opts))
@@ -108,6 +112,15 @@ int main(int argc, char *argv[])
     else
         cout << "Input: " << opts.input_file << endl;
 
+    // Get object classes list
+    object_classes = std::unique_ptr<ObjectClasses>(
+                             new ObjectClasses(opts.object_classes_list_file));
+    if (object_classes->GetNumClasses() == 0)
+    {
+        cout << "No object classes defined for this config." << endl;
+        return EXIT_FAILURE;
+    }
+
     // Run network
     bool status = RunConfiguration(opts);
     if (!status)
@@ -318,7 +331,8 @@ bool WriteFrameOutput(const ExecutionObjectPipeline &eop)
     }
 
     for (int i = k - 1; i >= 0; i--)
-        cout << k-i << ": " << imagenet_classes[sorted[i].second] << endl;
+        cout << k-i << ": "
+             << object_classes->At(sorted[i].second).label << endl;
 
     return true;
 }
@@ -338,6 +352,7 @@ void DisplayHelp()
     " -i camera<number>    Use camera as input\n"
     "                      video input port: /dev/video<number>\n"
     " -i <name>.{mp4,mov,avi}  Use video file as input\n"
+    " -l <objects_list>    Path to the object classes list file\n"
     " -f <number>          Number of frames to process\n"
     " -v                   Verbose output during execution\n"
     " -h                   Help\n";
index 128bc57695504963548a4451992258ab63080bd0..f569c0d148a9bf5ac345f5c86758170c2093e1a5 100644 (file)
@@ -45,7 +45,6 @@
 #include "execution_object.h"
 #include "execution_object_pipeline.h"
 #include "configuration.h"
-#include "../segmentation/object_classes.h"
 #include "../common/utils.h"
 #include "../common/video_utils.h"
 
index 50f3fe38cf00672c24584443bee3ac5232cbe024..7e9ca819209940a5f931053851427f26b3eaba6c 100644 (file)
@@ -30,8 +30,9 @@ include ../make.common
 
 LIBS     += -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio\
                        -lopencv_imgproc -lopencv_core
+LIBS     += -ljson-c
 
-SOURCES = main.cpp object_classes.cpp ../common/utils.cpp \
+SOURCES = main.cpp ../common/object_classes.cpp ../common/utils.cpp \
           ../common/video_utils.cpp
 
 $(EXE): $(TIDL_API_LIB) $(HEADERS) $(SOURCES)
diff --git a/examples/segmentation/jseg21_objects.json b/examples/segmentation/jseg21_objects.json
new file mode 100644 (file)
index 0000000..5dc0b26
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "network": "jseg21",
+  "objects": [
+    { "label": "background", "color_bgr": [ 127, 127, 127 ] },
+    { "label": "road",       "color_bgr": [   0, 255,   0 ] },
+    { "label": "pedestrian", "color_bgr": [   0,   0, 255 ] },
+    { "label": "road sign",  "color_bgr": [   0, 255, 255 ] },
+    { "label": "vehicle",    "color_bgr": [ 255,   0,   0 ] }
+  ]
+}
index 4e538b74cab714964810ef98bc8afabb6c292585..3e7238d1659d8da4303fda5f1f001a46df2a9b21 100644 (file)
@@ -44,7 +44,7 @@
 #include "executor.h"
 #include "execution_object.h"
 #include "configuration.h"
-#include "object_classes.h"
+#include "../common/object_classes.h"
 #include "../common/utils.h"
 #include "../common/video_utils.h"
 
@@ -57,8 +57,9 @@ using namespace cv;
 #define DEFAULT_CONFIG    "jseg21_tiscapes"
 #define DEFAULT_INPUT     "../test/testvecs/input/000100_1024x512_bgr.y"
 #define DEFAULT_INPUT_FRAMES  (9)
+#define DEFAULT_OBJECT_CLASSES_LIST_FILE "jseg21_objects.json"
 
-object_class_table_t *object_class_table;
+std::unique_ptr<ObjectClasses> object_classes;
 uint32_t orig_width;
 uint32_t orig_height;
 
@@ -91,6 +92,7 @@ int main(int argc, char *argv[])
     // Process arguments
     cmdline_opts_t opts;
     opts.config = DEFAULT_CONFIG;
+    opts.object_classes_list_file = DEFAULT_OBJECT_CLASSES_LIST_FILE;
     if (num_eves != 0) { opts.num_eves = 1;  opts.num_dsps = 0; }
     else               { opts.num_eves = 0;  opts.num_dsps = 1; }
     if (! ProcessArgs(argc, argv, opts))
@@ -108,8 +110,10 @@ int main(int argc, char *argv[])
     else
         cout << "Input: " << opts.input_file << endl;
 
-    // Get object class table
-    if ((object_class_table = GetObjectClassTable(opts.config)) == nullptr)
+    // Get object classes list
+    object_classes = std::unique_ptr<ObjectClasses>(
+                             new ObjectClasses(opts.object_classes_list_file));
+    if (object_classes->GetNumClasses() == 0)
     {
         cout << "No object classes defined for this config." << endl;
         return EXIT_FAILURE;
@@ -308,11 +312,10 @@ void CreateMask(uchar *classes, uchar *mb, uchar *mg, uchar* mr,
 {
     for (int i = 0; i < channel_size; i++)
     {
-        object_class_t *object_class = GetObjectClass(object_class_table,
-                                                      classes[i]);
-        mb[i] = object_class->color.blue;
-        mg[i] = object_class->color.green;
-        mr[i] = object_class->color.red;
+        const ObjectClass& object_class = object_classes->At(classes[i]);
+        mb[i] = object_class.color.blue;
+        mg[i] = object_class.color.green;
+        mr[i] = object_class.color.red;
     }
 }
 
@@ -391,6 +394,7 @@ void DisplayHelp()
     " -i camera<number>    Use camera as input\n"
     "                      video input port: /dev/video<number>\n"
     " -i <name>.{mp4,mov,avi}  Use video file as input\n"
+    " -l <objects_list>    Path to the object classes list file\n"
     " -f <number>          Number of frames to process\n"
     " -w <number>          Output image/video width\n"
     " -v                   Verbose output during execution\n"
index 3e67ba383c04c317801c1659b4e9b35d748419f0..ad7e33a5d44ce50cb35f875292b7f8310eef43f6 100644 (file)
@@ -30,8 +30,9 @@ include ../make.common
 
 LIBS     += -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio\
                        -lopencv_imgproc -lopencv_core
+LIBS     += -ljson-c
 
-SOURCES = main.cpp ../segmentation/object_classes.cpp ../common/utils.cpp \
+SOURCES = main.cpp ../common/object_classes.cpp ../common/utils.cpp \
           ../common/video_utils.cpp
 
 $(EXE): $(TIDL_API_LIB) $(HEADERS) $(SOURCES)
diff --git a/examples/ssd_multibox/jdetnet_objects.json b/examples/ssd_multibox/jdetnet_objects.json
new file mode 100644 (file)
index 0000000..a689b93
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "network": "jdetNet",
+  "objects": [
+    { "label": "some class 1",     "color_bgr": [ 255,   0, 255 ] },
+    { "label": "pedestrian",       "color_bgr": [   0,   0, 255 ] },
+    { "label": "road sign",        "color_bgr": [   0, 255, 255 ] },
+    { "label": "vehicle",          "color_bgr": [ 255,   0,   0 ] }
+  ]
+}
index b9c57dbbdb4308929de827c596c808f10f3ccd6d..a0cad9e27b7d18f9cb0cdea0f799abf643d575d4 100644 (file)
@@ -45,7 +45,7 @@
 #include "execution_object.h"
 #include "execution_object_pipeline.h"
 #include "configuration.h"
-#include "../segmentation/object_classes.h"
+#include "../common/object_classes.h"
 #include "../common/utils.h"
 #include "../common/video_utils.h"
 
@@ -58,8 +58,9 @@ using namespace cv;
 #define DEFAULT_CONFIG    "jdetnet"
 #define DEFAULT_INPUT     "../test/testvecs/input/preproc_0_768x320.y"
 #define DEFAULT_INPUT_FRAMES (1)
+#define DEFAULT_OBJECT_CLASSES_LIST_FILE "./jdetnet_objects.json"
 
-object_class_table_t *object_class_table;
+std::unique_ptr<ObjectClasses> object_classes;
 uint32_t orig_width;
 uint32_t orig_height;
 
@@ -93,6 +94,7 @@ int main(int argc, char *argv[])
     // Process arguments
     cmdline_opts_t opts;
     opts.config = DEFAULT_CONFIG;
+    opts.object_classes_list_file = DEFAULT_OBJECT_CLASSES_LIST_FILE;
     opts.num_eves = 1;
     opts.num_dsps = 1;
     if (! ProcessArgs(argc, argv, opts))
@@ -110,8 +112,10 @@ int main(int argc, char *argv[])
     else
         cout << "Input: " << opts.input_file << endl;
 
-    // Get object class table
-    if ((object_class_table = GetObjectClassTable(opts.config)) == nullptr)
+    // Get object classes list
+    object_classes = std::unique_ptr<ObjectClasses>(
+                             new ObjectClasses(opts.object_classes_list_file));
+    if (object_classes->GetNumClasses() == 0)
     {
         cout << "No object classes defined for this config." << endl;
         return EXIT_FAILURE;
@@ -352,19 +356,17 @@ bool WriteFrameOutput(const ExecutionObjectPipeline& eop,
         int   xmax  = (int) (out[i * 7 + 5] * width);
         int   ymax  = (int) (out[i * 7 + 6] * height);
 
-        object_class_t *object_class = GetObjectClass(object_class_table,
-                                                      label);
-        if (object_class == nullptr)  continue;
+        const ObjectClass& object_class = object_classes->At(label);
 
 #if 0
         printf("(%d, %d) -> (%d, %d): %s, score=%f\n",
-               xmin, ymin, xmax, ymax, object_class->label, score);
+               xmin, ymin, xmax, ymax, object_class.label, score);
 #endif
 
         cv::rectangle(frame, Point(xmin, ymin), Point(xmax, ymax),
-                      Scalar(object_class->color.blue,
-                             object_class->color.green,
-                             object_class->color.red), 2);
+                      Scalar(object_class.color.blue,
+                             object_class.color.green,
+                             object_class.color.red), 2);
     }
 
     // Resize to output width/height, keep aspect ratio
@@ -408,6 +410,7 @@ void DisplayHelp()
     " -i camera<number>    Use camera as input\n"
     "                      video input port: /dev/video<number>\n"
     " -i <name>.{mp4,mov,avi}  Use video file as input\n"
+    " -l <objects_list>    Path to the object classes list file\n"
     " -f <number>          Number of frames to process\n"
     " -w <number>          Output image/video width\n"
     " -v                   Verbose output during execution\n"