Bonjour,

Je crée un projet OpenCV 3.2 sous Qt creator,
et impossible de faire appel à watershed.
Mes arguments ne passent jamais.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
void Traitement :: Watershed (Image &image)
{
 
    Mat gray, thresh ;
    cvtColor(image.getResult(), gray, COLOR_BGR2GRAY);
    threshold(gray, thresh, 0, 255, THRESH_OTSU);
 
 
    // Traitement avant-plan
    Mat foreground;
    erode( thresh, foreground, Mat(), Point(-1, -1), 2 );
 
 
    // Traitement arrière plan
    Mat background, back;
    dilate ( thresh, background, Mat(), Point(-1, -1), 3 );
    threshold(background, back, 1, 128, 1);
 
 
    // Création des marqueurs
    Mat markers ;
    markers = foreground + back;
 
 
    Mat markers32, img;
 
 
    // Le problème commence à la conversion (image noire)
    markers.convertTo(markers32, CV_32SC1);
    gray.convertTo(img, CV_8UC3);
 
    watershed(img, markers32);
 
    image.setResult(markers32);
    image.addTraitement("Watershed");
}

J'ai vérifié tout au long de ma création du programme,
et l'image des marqueurs(markers) apparait bien.

Lorsque je la transforme en 32 bits, elle devient noire, mais c'est peut-être un problème d'affichage de imshow.
Par contre absolument impossible d'utiliser watershed(). Commenté ça marche, décommenté, ça plante...


Merci pour vos conseils.

Cordialement.