Shape detection/detection des formes

amel227 Messages postés 19 Date d'inscription jeudi 10 mai 2007 Statut Membre Dernière intervention 12 août 2009 - 6 mai 2009 à 17:52
amel227 Messages postés 19 Date d'inscription jeudi 10 mai 2007 Statut Membre Dernière intervention 12 août 2009 - 12 mai 2009 à 11:50
Hello everybody,

I'm asking for a code that detects rectangles and triangles in an image.
I use visual c++ .net 2005 and openCV.
Please, please, it is urgent.
Best regards.

Thanks a lot.

amel

3 réponses

Thaumasnot Messages postés 7 Date d'inscription vendredi 1 mai 2009 Statut Membre Dernière intervention 8 mai 2009
6 mai 2009 à 19:54
ok, thanks for the information
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
7 mai 2009 à 15:12
Hi,

Sorry but we are not alive search engine.

Google is better than us.

Here is a sample in C# using a wrapper around openCV.

There is probably the same code in C or C++ in the samples provided with openCV (pic3.png come frome openCV).
0
amel227 Messages postés 19 Date d'inscription jeudi 10 mai 2007 Statut Membre Dernière intervention 12 août 2009
12 mai 2009 à 11:50
BONJOUR A TOUS,

CECI EST LE CODE DE DETCTION DE TRIANGLES EN C# J'AI CONVERTI EN VC++ MAIS IL Y A QUELQUES INSTRUCTIONS QUE J'AI PAS ARRIVE 0 LES CONVERTIR EST CE QUE QUELQU1 PEUT M'AIDER

//Load the image from file

Image<Bgr, Byte> img =new Image<Bgr, byte>(fileNameTextBox.Text).Resize(400, 400, true);
 
//Convert the image to grayscale and filter out the noise
Image<Gray, Byte> gray = img.Convert<Gray, Byte>().PyrDown().PyrUp();
 
Gray cannyThreshold =new Gray(180);
Gray cannyThresholdLinking =new Gray(120);
Gray circleAccumulatorThreshold =new Gray(120);
 
CircleF[] circles = gray.HoughCircles(
cannyThreshold,
circleAccumulatorThreshold,
5.0, //Resolution of the accumulator used to detect centers of the circles
10.0, //min distance
5, //min radius
0 //max radius
)[0]; //Get the circles from the first channel
 
Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);
LineSegment2D[] lines = cannyEdges.HoughLinesBinary(
1, //Distance resolution in pixel-related units
Math.PI/45.0, //Angle resolution measured in radians.
20, //threshold
30, //min Line width
10//gap between lines
)[0]; //Get the lines from the first channel
 
#region Find triangles and rectangles
List<Triangle2DF> triangleList =new List<Triangle2DF>();
List<MCvBox2D> boxList =new List<MCvBox2D>();
 
using(MemStorage storage =new MemStorage())//allocate storage for contour approximation
for(Contour<Point> contours = cannyEdges.FindContours(); contours != null; contours = contours.HNext)
{

//SURTOUT CETTE PARTIE EN DESSOUS EST CE QUE VOUS POUVEZ MAIDER:

Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter*0.05, storage);
 
if(contours.Area>250)//only consider contours with area greater than 250
{
if(currentContour.Total==3)//The contour has 3 vertices, it is a triangle
{
Point[] pts = currentContour.ToArray();
triangleList.Add(new Triangle2DF(
pts[0],
pts[1],
pts[2]
));
}



MERCI BEAUCOUP

amel
0
Rejoignez-nous