Illia
Illia

Reputation: 369

Specific object recognition. [Python]

We have a technical task to recognize coal on the conveyor.

Input data: Photo of conveyor with (or without) coal.
Output data: Processed image with conveyor borders. (next step is recognizing volume of coal on the conveyor)

We've tried to process image to black/white, increasing contrast, blurring, but there's too much "noises" on the image. That is the first question: how to get rid of unwanted pixels on the image?

And the second question: how to properly detect conveyor (and then coal on it) on image?

Example of source image:

enter image description here

Upvotes: 2

Views: 766

Answers (2)

Asterisk
Asterisk

Reputation: 3574

Not sure if this helps, but you can try finding triangular shaped region using Hough transform.

Below is the example:

  1. Load and convert the image to gray
  2. Threshold and apply thinning
  3. Fit Hough transform

For example,

import cv2
from skimage import morphology

# Load image and convert to gray
img = cv2.imread('test.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Otsu threshold
t, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)

# Apply thinning    
thin = morphology.thin(thresh)
show_img(thin, 'Thinned')

# Hough transform: experiment with params here
from skimage.transform import probabilistic_hough_line

lines = probabilistic_hough_line(thin, threshold=100, line_length=10, line_gap=20)
print('Total lines={0}'.format(len(lines)))

# Plot lines over the input image
for p1, p2 in lines:
    cv2.line(img, p1, p2, (255, 0, 0), 4)

Images: enter image description here enter image description here enter image description here

Upvotes: 3

Piglet
Piglet

Reputation: 28994

Ask yourself why you want to solve this with a camera. There's like a houndred better, cheaper and more reliable ways to detect if there is coal on the conveyor. unless there can be something else or you want to get further information about that coal.

light barriers, point, line or areal distance-sensors (ultrasonic, optical,...) tactile switches, microphones, load cells, ...

If you insist on using cameras you have another ton of options which will depend on what exactly you want know.

The simplest straight forward approach is to check wether the conveyor looks empty rather than detecting the coal itself.

Also why do you have to detect the conveyor? I doubt it will walk away after you've installed your camera.

Upvotes: 0

Related Questions