Skip to content

A POC to classify images - Which cat(?) is on the food bowl?

Notifications You must be signed in to change notification settings

zwotzie/Raspberry-Motion-OpenCV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome To Which Cat Is There Eating

The purpose of this project is to analyze the eating habits of our cats - or a mouse.

Status of the Project

Right now, I'm fine-tuning motion. Motion is responsible for taking pictures when something moves in the camera. In reality, I do this in MotionEye because it's easier and there's a GUI where I can see.

Not sure if motion areas are quit good enough to train a tensorflow model. We will see.

The areas for small parts (the mouse) is not good enough. I used labelImg for that.

Hardware

  • Raspberry Pi 3B+
  • NightVision Camera
  • PIR (not jet in use)

The Camera:

https://www.ebay.de/itm/183394240431

  1. The Raspberry Pi Camera Board Features a 5MP (2592×1944 pixels)
  2. Half Size would be 1296x972, or normal mode 1600x1200
  3. Omnivision 5647 sensor in a fixed focus module
  4. The camera is capable of 2592 x 1944 pixel static images, and also supports 1080 p @ 30 fps, 720 p @ 60 fps and 640 x480 p 60/90 video recording
  5. Video: Supports 1080 p @ 30 fps, 720 p @ 60 fps and 640 x480 p 60/90 Recording 7.15-pin MIPI Camera Serial Interface The CSI bus is capable of extremely high data rates, and it exclusively carries pixel data to the BCM2835 processor

Some Links For Your Start:

First Commands on The Pi

see Raspberry Pi Readme

Motion Mysql Setup

Some DDL to Setup

see file ddl.sql

MotionEye's "Extra Motion Options" (Additional Configuration For Motion)

database_type mysql
database_dbname motion
database_host localhost
database_port 3306
database_user motion
database_password mypasswordformotion

sql_log_picture on

# sql_query_start insert into motion_events(camera) values('%t')
sql_query_start insert into motion_events(camera, start_time) values ('%t', '%Y-%m-%d %T')
sql_query_stop update motion_events set end_time='%Y-%m-%d %T' where event_id=%{dbeventid}
sql_query insert into images (camera, event_id, filename, frame_number, file_type, image_width, image_height, motion_center_x, motion_center_y, changed_pixels, noise_level, motion_area_height, motion_area_width, threshold) values('%t', %{dbeventid}, '%f', %q, %n, %w, %h, %K, %L, %D, %N, %J, %i, %o)

Some Peculiarities

First thing what I'm mention is, that the sql_query_stop is not working. I filed a bug to: Motion-Project/motion#879

Second, the mask is loosing all left squares after saving and reopening. That's kind of weird.

media_path in motioneye.conf is ignored.

Entering Debug Loging for Motion and MotionEye

sometimes you need more logging information and this will help:

vi /etc/motioneye/motioneye.conf
# set log_level:
log_level debug

Next Steps ML - OpenCV - tensorflow

Not jet implemented!

check motion capture with imagemagick

therefore is a script 0_test_motion_areas.py

create csv for training data

filename,width,height,class,xmin,ymin,xmax,ymax

Tensorflow

get tensorflow models:

git clone https://github.com/tensorflow/models.git

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

// pip install protobuf

sudo apt install protobuf-compiler python-dev python-tk // NVIDIA/DIGITS#187 (comment) sudo apt install python3-dev python3-matplotlib

virtualenv --system-site-packages -p python3 ~/py3 source ~/py3/bin/activate

pip install tensorflow-gpu pip install Cython contextlib2 pillow lxml jupyter

(venv) ~/git/github.com/tensorflow/models/research$ protoc object_detection/protos/*.proto --python_out=.

git clone https://github.com/cocodataset/cocoapi.git cd cocoapi/PythonAPI make cp -r pycocotools <path_to_tensorflow>/models/research/

https://cloud.google.com/solutions/creating-object-detection-application-tensorflow

http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_11_06_2017.tar.gz http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_11_06_2017.tar.gz ... and put the content () in model/ https://github.com/tensorflow/models/blob/master/research/object_detection/samples/configs

label the images, if you have to

pip install labelImg

but first i will try to get good results with motion areas.

Testing the Installation

You can test that you have correctly installed the Tensorflow Object Detection API by running the following command:

python object_detection/builders/model_builder_test.py

get it running...

tensorflow/models#3786 (comment)

sorry, but run it with python 2

Tensorboard

tensorboard --logdir=${MODEL_DIR} --port 8008

About

A POC to classify images - Which cat(?) is on the food bowl?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published