Lakshay JunejaAshish JhaPankaj Baranwal
Published © Apache-2.0

Where's my stuff?? - Find your misplaced things with Alexa!

Find all your misplaced stuff with Amazon Alexa. Next time, you don't need to search entire house to locate your phone, remote etc!

IntermediateWork in progress5 hours5,275
Where's my stuff?? - Find your misplaced things with Alexa!

Things used in this project

Story

Read more

Schematics

Servo motor connections with Arduino Uno

Code

Modifications made in image.c file of darknet

C/C++
void draw_detections(image im, int num, float thresh, box *boxes, float **probs, float **masks, char **names, image **alphabet, int classes)
{
   // Pointer for file handling
   FILE *fptr;
   int i,j;
   // Open the following files in write access mode
   fptr = fopen("program.txt", "w+");
   for(i = 0; i < num; ++i){
       // labelstr will eventually contain label of recognized image
       char labelstr[4096] = {0};
       int class = -1;
       for(j = 0; j < classes; ++j){
           if (probs[i][j] > thresh){
               if (class < 0) {
                   strcat(labelstr, names[j]);
                   class = j;
               } else {
                   strcat(labelstr, ", ");
                   strcat(labelstr, names[j]);
               }
               printf("%s: %.0f%%\n", names[j], probs[i][j]*100);
           }
       }
       if(class >= 0){
           int width = im.h * .006;
           int offset = class*123457 % classes;
           float red = get_color(2,offset,classes);
           float green = get_color(1,offset,classes);
           float blue = get_color(0,offset,classes);
           float rgb[3];
           //width = prob*20+2;
           rgb[0] = red;
           rgb[1] = green;
           rgb[2] = blue;
           box b = boxes[i];
           int left  = (b.x-b.w/2.)*im.w;
           int right = (b.x+b.w/2.)*im.w;
           int top   = (b.y-b.h/2.)*im.h;
           int bot   = (b.y+b.h/2.)*im.h;
           if(left < 0) left = 0;
           if(right > im.w-1) right = im.w-1;
           if(top < 0) top = 0;
           if(bot > im.h-1) bot = im.h-1;
           if(fptr == NULL)
           {
             goto X;
           }
           else{
               // Add object details in program.txt for further processing
               char buf[100];
               sprintf(buf,"%s:(%d,%d,%d,%d)\n",labelstr,left,top,right,bot);
               fprintf(fptr,"%s", buf);
           } 
           // printf("Bounding Box: Left=%d, Top=%d, Right=%d, Bottom=%d\n", left, top, right, bot);
       X:  draw_box_width(im, left, top, right, bot, width, red, green, blue);
           if (alphabet) {
               image label = get_label(alphabet, labelstr, (im.h*.03)/10);
               draw_label(im, top + width, left, label, rgb);
               free_image(label);
           }
           if (masks){
               image mask = float_to_image(14, 14, 1, masks[i]);
               image resized_mask = resize_image(mask, b.w*im.w, b.h*im.h);
               image tmask = threshold_image(resized_mask, .5);
               embed_image(tmask, im, left, top);
               free_image(mask);
               free_image(resized_mask);
               free_image(tmask);
           }
       }
   }
   // Finally, close the files
   fclose(fptr);
}

Where's my stuff?? Alexa Skill

Please refer to the readme.md to know how to implement this code.

RPi & server communication for object recognition and tracking

Credits

Lakshay Juneja

Lakshay Juneja

1 project • 0 followers
Ashish Jha

Ashish Jha

1 project • 0 followers
Pankaj Baranwal

Pankaj Baranwal

1 project • 2 followers
I am a student developer and coding has been my mother tongue since 4 years. Hardware is my way of using code in the physical world!
Thanks to Joseph Redmond.

Comments