Jump to content

Capture image from camera.


photo

Recommended Posts

Hey everyone, 

I am currently working on drone sim, where I would like to capture image and save it to jpg or png. Is there any way how to resolve this problem with C# script? I would be fine to create resolution at least 1080p. 4000x6000 would be ideal.

Thanks 
Roman

Link to comment

Dear @roman.ligocki,

Do you intend following? This is from C++. But you get an Idea about how to do it in C#. I see that you want to capture the image of simulated Virtual camera, don't you?

    ImagePtr imgGrabScreen = Image::create();
	m_textureScreenGrab->getImage(imgGrabScreen);
	string szFilePath = "..\\screengrabs\\finalsave.png";
	imgGrabScreen->save(szFilePath.c_str());

If texture format is not 8-bit then after grabbing the image you may convert the format for saving using imgGrabScreen->convertToFormat(FORMAT_RGBA8 );

Beware that this process is texture image transfer from GPU to System memory. Also if the saving happens in main rendering thread it will pause a thread little as file writing is expensive. You may get image in one thread and save it in another if you want smooth FPS for Rendering thread.

I hope this is what you need.

Regards,

Rohit

Link to comment
×
×
  • Create New...