Converting rgb data to cv2 image









up vote
-3
down vote

favorite
1












I'm trying to use Webots simulator for simulation of the autonomous vehicle. Currently, in order to find the position of the vehicle I need to detect the lanes. To do so, I'm using an algorithm based on the open CV in python and its code loads an existing image by imread to find the lanes. From the webots camera I can get the rgb array but saving the image and reading the saved image is not real time. I need to create the object which has all features of an object created by imread. I think there should be a more fast way to do so but I don't have any experience in image processing!



I have used following to get the camera data:



from vehicle import Driver
import main as LD

camera = driver.getCamera("camera")
camera.enable(20)
camera.recognitionEnable(50)

while driver.step() != -1:
distance = LD(camera.getImage)


In main, LD(imread('/path/to/image')) will return the distance of the car to the middle of the lanes. Based on the Webots documentation for a camera, the getImage returns an image coded as a sequence of three bytes representing the red, green and blue levels of a pixel. Pixels are stored in horizontal lines ranging from the top left-hand side of the image down to bottom right-hand side.



I'm so welcome to your suggestions.










share|improve this question























  • So you have a 1D array, 2D array or a 3D array for the input image ?
    – ZdaR
    Nov 11 at 6:16










  • Please post a code example.
    – Florian Echtler
    Nov 11 at 8:07










  • @FlorianEchtler I have updated the question.
    – Mojmal
    Nov 12 at 17:25











  • @ZdaR The question has been updated.
    – Mojmal
    Nov 12 at 17:26














up vote
-3
down vote

favorite
1












I'm trying to use Webots simulator for simulation of the autonomous vehicle. Currently, in order to find the position of the vehicle I need to detect the lanes. To do so, I'm using an algorithm based on the open CV in python and its code loads an existing image by imread to find the lanes. From the webots camera I can get the rgb array but saving the image and reading the saved image is not real time. I need to create the object which has all features of an object created by imread. I think there should be a more fast way to do so but I don't have any experience in image processing!



I have used following to get the camera data:



from vehicle import Driver
import main as LD

camera = driver.getCamera("camera")
camera.enable(20)
camera.recognitionEnable(50)

while driver.step() != -1:
distance = LD(camera.getImage)


In main, LD(imread('/path/to/image')) will return the distance of the car to the middle of the lanes. Based on the Webots documentation for a camera, the getImage returns an image coded as a sequence of three bytes representing the red, green and blue levels of a pixel. Pixels are stored in horizontal lines ranging from the top left-hand side of the image down to bottom right-hand side.



I'm so welcome to your suggestions.










share|improve this question























  • So you have a 1D array, 2D array or a 3D array for the input image ?
    – ZdaR
    Nov 11 at 6:16










  • Please post a code example.
    – Florian Echtler
    Nov 11 at 8:07










  • @FlorianEchtler I have updated the question.
    – Mojmal
    Nov 12 at 17:25











  • @ZdaR The question has been updated.
    – Mojmal
    Nov 12 at 17:26












up vote
-3
down vote

favorite
1









up vote
-3
down vote

favorite
1






1





I'm trying to use Webots simulator for simulation of the autonomous vehicle. Currently, in order to find the position of the vehicle I need to detect the lanes. To do so, I'm using an algorithm based on the open CV in python and its code loads an existing image by imread to find the lanes. From the webots camera I can get the rgb array but saving the image and reading the saved image is not real time. I need to create the object which has all features of an object created by imread. I think there should be a more fast way to do so but I don't have any experience in image processing!



I have used following to get the camera data:



from vehicle import Driver
import main as LD

camera = driver.getCamera("camera")
camera.enable(20)
camera.recognitionEnable(50)

while driver.step() != -1:
distance = LD(camera.getImage)


In main, LD(imread('/path/to/image')) will return the distance of the car to the middle of the lanes. Based on the Webots documentation for a camera, the getImage returns an image coded as a sequence of three bytes representing the red, green and blue levels of a pixel. Pixels are stored in horizontal lines ranging from the top left-hand side of the image down to bottom right-hand side.



I'm so welcome to your suggestions.










share|improve this question















I'm trying to use Webots simulator for simulation of the autonomous vehicle. Currently, in order to find the position of the vehicle I need to detect the lanes. To do so, I'm using an algorithm based on the open CV in python and its code loads an existing image by imread to find the lanes. From the webots camera I can get the rgb array but saving the image and reading the saved image is not real time. I need to create the object which has all features of an object created by imread. I think there should be a more fast way to do so but I don't have any experience in image processing!



I have used following to get the camera data:



from vehicle import Driver
import main as LD

camera = driver.getCamera("camera")
camera.enable(20)
camera.recognitionEnable(50)

while driver.step() != -1:
distance = LD(camera.getImage)


In main, LD(imread('/path/to/image')) will return the distance of the car to the middle of the lanes. Based on the Webots documentation for a camera, the getImage returns an image coded as a sequence of three bytes representing the red, green and blue levels of a pixel. Pixels are stored in horizontal lines ranging from the top left-hand side of the image down to bottom right-hand side.



I'm so welcome to your suggestions.







opencv real-time rgb webots






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 17:24

























asked Nov 11 at 6:11









Mojmal

12




12











  • So you have a 1D array, 2D array or a 3D array for the input image ?
    – ZdaR
    Nov 11 at 6:16










  • Please post a code example.
    – Florian Echtler
    Nov 11 at 8:07










  • @FlorianEchtler I have updated the question.
    – Mojmal
    Nov 12 at 17:25











  • @ZdaR The question has been updated.
    – Mojmal
    Nov 12 at 17:26
















  • So you have a 1D array, 2D array or a 3D array for the input image ?
    – ZdaR
    Nov 11 at 6:16










  • Please post a code example.
    – Florian Echtler
    Nov 11 at 8:07










  • @FlorianEchtler I have updated the question.
    – Mojmal
    Nov 12 at 17:25











  • @ZdaR The question has been updated.
    – Mojmal
    Nov 12 at 17:26















So you have a 1D array, 2D array or a 3D array for the input image ?
– ZdaR
Nov 11 at 6:16




So you have a 1D array, 2D array or a 3D array for the input image ?
– ZdaR
Nov 11 at 6:16












Please post a code example.
– Florian Echtler
Nov 11 at 8:07




Please post a code example.
– Florian Echtler
Nov 11 at 8:07












@FlorianEchtler I have updated the question.
– Mojmal
Nov 12 at 17:25





@FlorianEchtler I have updated the question.
– Mojmal
Nov 12 at 17:25













@ZdaR The question has been updated.
– Mojmal
Nov 12 at 17:26




@ZdaR The question has been updated.
– Mojmal
Nov 12 at 17:26

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246312%2fconverting-rgb-data-to-cv2-image%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246312%2fconverting-rgb-data-to-cv2-image%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto