How to input the data of RGB image gotten by Coppeliasim into Matlab

Typically: "How do I... ", "How can I... " questions
Post Reply
zerobb
Posts: 2
Joined: 07 Apr 2024, 16:40

How to input the data of RGB image gotten by Coppeliasim into Matlab

Post by zerobb »

In matlab I use
[ImageRGB,resolution] = sim.getVisionSensorImg(Hsensor)
to obtain RGB data from Coppeliasim.

But when I use command in Matlab as follows:
Image = reshape(ImageRGB,[resolution{1} resolution{2} 3]) ;
figure;imshow(double(Image)/255,[]);
The image showed in Matlab is not correct. What's wrong?

Most of examples are in Python with OpenCV. I need the example in Matlab to display the RGB image.

fferri
Posts: 1231
Joined: 09 Sep 2013, 19:28

Re: How to input the data of RGB image gotten by Coppeliasim into Matlab

Post by fferri »

From zmqRemoteApi/clients/matlab/synchronousImageTransmission.m:

Code: Select all

    [img, resX, resY] = sim.getVisionSensorCharImage(visionSensorHandle);
    % display image in MATLAB:
    imshow(flip(permute(reshape(img, 3, resY, resX), [3 2 1]), 1));

Post Reply