How to identify a white caliber panel for measuring water level?

I am working on a project where I need to measure the water level using a white-caliber panel. Currently my approach is:

  • segmentation of a white caliber board.
  • Measure the water level at the level of the calibration plate.

But I'm stuck in segmenting the meter board. I avoid using color-based segmentation since I need it to be invariant to light changes, so I detect edges using morphological operations. I have this image:

enter image description hereenter image description here

The result of morphological operations seems promising. The edges on the white-caliber panel are sharper than the others. But I still don’t know how to segment a board correctly. Can you suggest a board segmentation algorithm? Or ask if you have another algorithm for measuring water level.

Here is my code:

#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { cv::Mat src = cv::imread("image.jpg"); if (!src.data) return -1; cv::Mat bw; cv::cvtColor(src, bw, CV_BGR2GRAY); cv::medianBlur(bw, bw, 3); cv::Mat dilated, eroded; cv::dilate(bw, dilated, cv::Mat()); cv::erode(bw, eroded, cv::Mat()); bw = dilated - eroded; cv::imshow("src", src); cv::imshow("bw", bw); cv::waitKey(); return 0; } 

I use C ++, but I am open to other implementations in Matlab / Mathematica.

+4
source share
2 answers

If the camera is truly stationary, you can use this type of quick and dirty approach:

 im= rgb2gray(imread('img.jpg')); imr=imrotate(im,1); a=imr(100:342,150); plot(a) 

enter image description here

Minima shown on the chart are from 10 (left) to 1 (right) in the indicator scale. You can use the peak detector to determine the location and interpolate the water level between them. So, there is no real need for image processing ...

0
source

Why are you segmenting the calibration panel anyway? You just want to find it in the picture, that's all. You do not need to look for the relative arrangement of the segments. 5 will always be between 4 and 6.

As you probably noticed, you can find a rough layout of the meter board by looking for an area with a high level of contrast. Using matchTemplate , you can find the exact location. (Given that the camera is locked, you can skip the first step and directly call matchTemplate ).

0
source

Source: https://habr.com/ru/post/1469505/


All Articles