# Line detection and timestamps, video, Python

I am working on a scientific project. I am trying to figure out how to calculate the melting speed of ice cores by use of OpenCv and Python. The ice cores melt downwards.

To simplify the problem I would like first to detect pencil lines (5 cm between each of them) on a piece of paper that is moving downwards. Every time a line passes a certain point, a timestamp must be made and send to a log file.From that information the speed will be calculated. Later the lines will be made on the ice cores.

I need to get started, so I have looked at the sample files that come with the OpenCV library, and I found the facedetect.py example. Could this sample be uses and adjusted to detect lines instead of faces? Or is there a better sample to look at?

Thank you!

edit retag close merge delete

2

If you post some pictures of your melting ice, you have a much better chance to find ideas. And about lines, they are usually easily detected with Hough Transform. See the hough.cpp sample

( 2012-07-27 08:56:56 -0500 )edit

Sort by » oldest newest most voted

Lines and faces are completely different objects, so you shouldn't count on facedetect.py. Try to start from the Hough transform. You can grep OpenCV C/C++ samples for this function, there should be some useful code samples.

HoughLines should be a perfect function for pencils on paper, but melting ice will produce curves, not strict edges. Nevertheless you can start with this function, and switch later to tracking with Optical Flow or something. You can put several dozens of points to every edge, and then track how they move down. But you should constrain the Optical Flow in a way so it searches for new points' positions in the vertical direction only. If the ice is melting slowly, you can even implement your own search with a block-matching-like technique.

more

Thanks a lot! I will look at it.

( 2012-07-28 06:33:50 -0500 )edit

If your paper background is quite plain, you can do some simple binary thresholding to get the pencil lines. Then projecting the lines onto the y axis and doing a min for a range will give you the lowest point of a particular pencil line and you can set some predefined points in y that you are looking for to be logged. Whenever the min(projection(y)) is lower than your predefined line, you trigger the rest of the code. However the assumption is that the various pencil lines do not overlap in the projection space.

more

Official site

GitHub

Wiki

Documentation