GithubHelp home page GithubHelp logo

intel-iot-devkit / object-size-detector-python Goto Github PK

View Code? Open in Web Editor NEW
26.0 15.0 20.0 12.47 MB

Monitor mechanical bolts as they move down a conveyor belt. When a bolt of an irregular size is detected, this solution emits an alert.

Home Page: https://software.intel.com/content/www/us/en/develop/topics/iot/reference-implementations/object-size-detector.html

License: BSD 3-Clause "New" or "Revised" License

Python 57.89% Jupyter Notebook 38.70% Shell 3.40%
reference-implementation deep-learning inference computer-vision edge-computing edge edge-ai image-recognition object-detection intel

object-size-detector-python's Introduction

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel. Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. Intel no longer accepts patches to this project.

Object Size Detector

Details
Target OS: Ubuntu* 18.04 LTS
Programming Language: Python* 3.6
Time to Complete: 45 min

Defect

What it does

This application demonstrates how to use CV to detect and measure the approximate size of assembly line parts. It is designed to work with an assembly line camera mounted above the assembly line belt. The application monitors mechanical parts as they are moving down the assembly line and raises an alert if it detects a part on the belt outside a specified size range.

Requirements

Hardware

  • 6th to 8th generation Intel® Core™ processor with Iris® Pro graphics or Intel® HD Graphics

Software

  • Ubuntu* 18.04 LTS
    NOTE: Use kernel versions 4.14+ with this software.
    Determine the kernel version with the below uname command.

    uname -a
    
  • Intel® Distribution of OpenVINO™ toolkit 2020 R3 release toolkit

How It works

This object size detector works with a video source, such as a camera. The application captures video frames and processes the frame data with OpenCV algorithms. It detects objects on the assembly line and calculates the length and width of the objects. If the calculated length and width is not within a predefined range, the application raises an alert to notify the assembly line operator. Optionally, the application sends data to a message queuing telemetry transport (MQTT) machine, or machine messaging server, as a part of an assembly line data analytics system.

app image Architectural Diagram

Setup

Get the code

Steps to clone the reference implementation: (object-size-detector-python)

sudo apt-get update && sudo apt-get install git
git clone https://github.com/intel-iot-devkit/object-size-detector-python.git

Install Intel® Distribution of OpenVINO™ toolkit

Before running the application, install the Intel® Distribution of OpenVINO™ toolkit. For details, see Installing the Intel® Distribution of OpenVINO™ toolkit for Linux*

Other dependencies

Mosquitto*

Mosquitto is an open source message broker that implements the MQTT protocol. The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model.

To install the dependencies of the RI, run the below command:

cd <path_to_the_object-size-detector-python_directory>
./setup.sh

The Config File

The resources/config.json contains the path to the videos that will be used by the application. The config.json file is of the form name/value pair, video: <path/to/video>

Example of the config.json file:

{

    "inputs": [
	    {
            "video": "videos/video1.mp4"
        }
    ]
}

Which Input video to use

The application works with any input video. Find sample videos for object detection here.

For first-use, we recommend using the bolt-multi-size-detection video.The video is automatically downloaded to the resources/ folder. For example:
The config.json would be:

{

    "inputs": [
	    {
            "video": "sample-videos/bolt-multi-size-detection.mp4"
        }
    ]
}

To use any other video, specify the path in config.json file

Using the Camera instead of video

Replace the path/to/video in the resources/config.json file with the camera ID, where the ID is taken from the video device (the number X in /dev/videoX).

On Ubuntu, list all available video devices with the following command:

ls /dev/video*

For example, if the output of above command is /dev/video0, then config.json would be::

{

    "inputs": [
	    {
            "video": "0"
        }
    ]
}

Setup the Environment

Configure the environment to use the Intel® Distribution of OpenVINO™ toolkit once per session by running the source command on the command line:

source /opt/intel/openvino/bin/setupvars.sh

Note: This command needs to be executed only once in the terminal where the application will be executed. If the terminal is closed, the command needs to be executed again.

Run the Application

Change the current directory to the git-cloned application code location on your system:

cd <path-to-object-size-detector-python>/application

To see a list of the various options, invoke the help output of this application with the help parameter:

python3 object_size_detector.py -h

Run the application using the below command if field of view and distance between the object and camera in millimeters are not known.

Using input as videofile:

python3 object_size_detector.py -minl=228 -minw=28 -maxl=250 -maxw=45

Run the application using the below command if field of view and distance between the object and camera in millimeters are known.

Using input as videofile:

python3 object_size_detector.py -minl=228 -minw=28 -maxl=250 -maxw=45 -fv=60 -d=370

Note:
User can get field of view from camera specifications. The minl, minw, maxl and maxw parameters set the values for the minimum and maximum values for length and width. If a part’s length and width is not within this range, the application issues an alert.

Subscribe the data

Open a new terminal and execute the below commands:

To run the mosquitto server

mosquitto

Note: If the output of the above command is

1543918812: mosquitto version 1.4.8 (build date Wed, 05 Sep 2018 15:51:27 -0300) starting
1543918812: Using default config.
1543918812: Opening ipv4 listen socket on port 1883.
1543918812: Error: Address already in use

It means mosquitto server is already running in the background.

To Subscribe the data

mosquitto_sub -h localhost -t defects/counter

object-size-detector-python's People

Contributors

eashtianjr avatar intelcpdp avatar madhuri-t avatar sfblackl-intel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

object-size-detector-python's Issues

Distance between camera and object.

Hi,

What difference does it make if the distance between the object and camera is not given ? Is it crucial to get the correct output ?

Thanks and regards.

Sudheer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.