# Revision history [back]

Having a real image could help to give a good answer. Here are some ideas:

• If you worry about the luminosity, use a luminosity invariant color space (e.g. HSV). Then use a segmentation on the hue and saturation channel (inRange function) to detect the ball and the lines:

imageHSV = cvtColor(image,COLOR_BGR2HSV);
ball = inRange(imageHSV,Scalar(20,100,100),Scalar(30,255,255)); //you have to define the values yourself
lines = inRange(imageHSV,Scalar(50,100,100),Scalar(70,255,255));

• for the green lines, use a horizontal integration on the segmented image (if the tube is always vertical) or a contour detection to get the position of the limits. Same for the ball.

• you can recognize the limits once (if the tube is static) or in every frame. Normally the operation is fast, so it won't pose any problems for real time processing.