IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

Plusieurs graphique en figure + Superposition avec une image


Sujet :

MATLAB

  1. #1
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2009
    Messages : 1
    Par défaut Plusieurs graphique en figure + Superposition avec une image
    Bonjour, étant un débutant sur Matlab, je me permets un post sur ce forum.

    J'ai crée un programme qui a partir d'une matrice de rotation et de translation, ainsi que 4 points (représentant un rectangle), me permet de projeter le rectangle sur un plan photo.

    Première étape - modification des points celon la translation et la rotation
    Deuxième étape - Prise en compte de la matrice interne à la caméra pour prendre en compte la calibration de la caméra.

    Plusieurs problèmes:

    -Comment faire apparaitre les deux graphiques en même temps ? Avant et après calibration+projection sur le plan photo
    -Comment faire apparaitre en arrière plan une image (ici, mon rectangle pris en photo), ainsi que mon graphique pour voir si ma projection correspond à la réalité de ma photo.

    Merci d'avance

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    % Program
     
    clear all;
     
     
     
    % Input initialisation
     
     
    R=[pi/4;0;pi/2]; % Matrix with yaw, pitch and roll for the rotation matrix
    T=[4;8;2]; % Translation matrix
     
    point(1).coord=[0;0;0];
    point(2).coord=[0;1000;0];
    point(3).coord=[1000;1000;0];
    point(4).coord=[1000;0;0];
    point(5).coord=point(1).coord;
     
     
    % Program code
     
    KK=[                        % Camera Matrix 
        20195.5365,0,1823.5;    % [fc(1),alpha(c)*fc(1),cc(1)
        0,20218.67258,1367.5;   % 0,fc(2),cc(2)
        0,0,1                   % 0,0,1]
        ];
     
     
    yaw=R(1); % X angle (rad)
    pitch=R(2); % Y angle (rad)
    roll=R(3); % Z angle (rad)
     
    ROT=[
        cos(yaw)*cos(pitch),-cos(roll)*sin(yaw)+cos(yaw)*sin(pitch)*sin(roll),cos(yaw)*cos(roll)*sin(pitch)+sin(yaw)*sin(roll);
        cos(pitch)*sin(yaw),cos(yaw)*cos(roll)+sin(yaw)*sin(pitch)*sin(roll),cos(roll)*sin(yaw)*sin(pitch)-cos(yaw)*sin(roll);
        -sin(pitch),cos(pitch)*sin(roll),cos(pitch)*cos(roll)
        ]; % Rotation matrix
     
    k=length(point); % Number of point
     
    for i=1:k
    rotatepoint(i).coord=ROT*point(i).coord+T; % Point moving with rotation and translation
    end
     
    MatrixX=[]; % We create matrix for coordinate X of points after rotation and translation
    MatrixY=[]; % We create matrix for coordinate Y of points after rotation and translation
    MatrixZ=[]; % We create matrix for coordinate Z of points after rotation and translation
     
    for i=1:k
    MatrixX=[MatrixX; rotatepoint(i).coord(1)]; % We put X coordinates inside the matrixX
    MatrixY=[MatrixY; rotatepoint(i).coord(2)]; % We put Y coordinates inside the matrixY
    MatrixZ=[MatrixZ; rotatepoint(i).coord(3)]; % We put Z coordinates inside the matrixZ
    end
     
    plot3(MatrixX,MatrixY,MatrixZ),
    grid,
    xlabel('Axe des x')
    ylabel('Axe des y')
    zlabel('Axe des z')
    Title('Forme après rotation et translation')
     
     
    % We look the rectangle in the space
     
    for j=1:k
        projectionpoint(j).coord=(1/rotatepoint(j).coord(3))*KK*rotatepoint(j).coord;
    end
     
    ProjectionmatrixX=[]; % We create matrix for coordinate X of points after rotation and translation
    ProjectionmatrixY=[]; % We create matrix for coordinate Y of points after rotation and translation
    ProjectionmatrixZ=[]; % We create matrix for coordinate Z of points after rotation and translation
     
    for j=1:k
    ProjectionmatrixX=[ProjectionmatrixX; projectionpoint(j).coord(1)]; % We put X coordinates inside the matrixX
    ProjectionmatrixY=[ProjectionmatrixY; projectionpoint(j).coord(2)]; % We put Y coordinates inside the matrixY
    ProjectionmatrixZ=[ProjectionmatrixZ; projectionpoint(j).coord(3)]; % We put Z coordinates inside the matrixZ
    end
     
    plot3(ProjectionmatrixX,ProjectionmatrixY,ProjectionmatrixZ),
    grid,
    xlabel('Axe des x')
    ylabel('Axe des y')
    zlabel('Axe des z')
    Title('Forme après toutes les corrections')
     
    % We look the rectangle in the space camera

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 317
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 317
    Par défaut
    Voici ton code un peu modifié :

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    % Program
    
    clear all;
    
    
    
    % Input initialisation
    
    
    R=[pi/4;0;pi/2]; % Matrix with yaw, pitch and roll for the rotation matrix
    T=[4;8;2]; % Translation matrix
    
    point(1).coord=[0;0;0];
    point(2).coord=[0;1000;0];
    point(3).coord=[1000;1000;0];
    point(4).coord=[1000;0;0];
    point(5).coord=point(1).coord;
    
    
    % Program code
    
    KK=[                        % Camera Matrix 
        20195.5365,0,1823.5;    % [fc(1),alpha(c)*fc(1),cc(1)
        0,20218.67258,1367.5;   % 0,fc(2),cc(2)
        0,0,1                   % 0,0,1]
        ];
        
    
    yaw=R(1); % X angle (rad)
    pitch=R(2); % Y angle (rad)
    roll=R(3); % Z angle (rad)
    
    ROT=[
        cos(yaw)*cos(pitch),-cos(roll)*sin(yaw)+cos(yaw)*sin(pitch)*sin(roll),cos(yaw)*cos(roll)*sin(pitch)+sin(yaw)*sin(roll);
        cos(pitch)*sin(yaw),cos(yaw)*cos(roll)+sin(yaw)*sin(pitch)*sin(roll),cos(roll)*sin(yaw)*sin(pitch)-cos(yaw)*sin(roll);
        -sin(pitch),cos(pitch)*sin(roll),cos(pitch)*cos(roll)
        ]; % Rotation matrix
    
    k=length(point); % Number of point
    
    for i=1:k
    rotatepoint(i).coord=ROT*point(i).coord+T; % Point moving with rotation and translation
    end
    
    MatrixX=[]; % We create matrix for coordinate X of points after rotation and translation
    MatrixY=[]; % We create matrix for coordinate Y of points after rotation and translation
    MatrixZ=[]; % We create matrix for coordinate Z of points after rotation and translation
    
    for i=1:k
    MatrixX=[MatrixX; rotatepoint(i).coord(1)]; % We put X coordinates inside the matrixX
    MatrixY=[MatrixY; rotatepoint(i).coord(2)]; % We put Y coordinates inside the matrixY
    MatrixZ=[MatrixZ; rotatepoint(i).coord(3)]; % We put Z coordinates inside the matrixZ
    end
    
    figure
    hold on
    view(3)
    
    plot3(MatrixX,MatrixY,MatrixZ),
    grid,
    xlabel('Axe des x')
    ylabel('Axe des y')
    zlabel('Axe des z')
    title('Forme après rotation et translation')
    
    
    % We look the rectangle in the space
    
    for j=1:k
        projectionpoint(j).coord=(1/rotatepoint(j).coord(3))*KK*rotatepoint(j).coord;
    end
    
    ProjectionmatrixX=[]; % We create matrix for coordinate X of points after rotation and translation
    ProjectionmatrixY=[]; % We create matrix for coordinate Y of points after rotation and translation
    ProjectionmatrixZ=[]; % We create matrix for coordinate Z of points after rotation and translation
    
    for j=1:k
    ProjectionmatrixX=[ProjectionmatrixX; projectionpoint(j).coord(1)]; % We put X coordinates inside the matrixX
    ProjectionmatrixY=[ProjectionmatrixY; projectionpoint(j).coord(2)]; % We put Y coordinates inside the matrixY
    ProjectionmatrixZ=[ProjectionmatrixZ; projectionpoint(j).coord(3)]; % We put Z coordinates inside the matrixZ
    end
    
    plot3(ProjectionmatrixX,ProjectionmatrixY,ProjectionmatrixZ),
    % grid,
    % xlabel('Axe des x')
    % ylabel('Axe des y')
    % zlabel('Axe des z')
    % title('Forme après toutes les corrections')
    
    % We look the rectangle in the space camera

Discussions similaires

  1. Superposition d'une image avec un quiver
    Par généric dans le forum Images
    Réponses: 2
    Dernier message: 05/05/2015, 14h52
  2. Superposition d'un graphique avec une image
    Par victorberard dans le forum LabVIEW
    Réponses: 5
    Dernier message: 05/02/2014, 10h53
  3. Superposition d'une image et d'un graphique loglog
    Par VincentLR dans le forum Images
    Réponses: 3
    Dernier message: 18/09/2007, 21h13
  4. Réponses: 6
    Dernier message: 03/04/2007, 21h40
  5. Centrage de texte avec une image en arriere plan
    Par MasterOfChakhaL dans le forum Balisage (X)HTML et validation W3C
    Réponses: 7
    Dernier message: 26/08/2005, 19h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo