Closed GitJoustEdicts closed 3 months ago
The flip operation (ReverseX/ReverseY) in the camera settings are sensor features.
Rotation is not something a camera like ours can do, as it only looks at the image data in linear fashion. It therefore needs to be done on the host.
ic4 does not support any image manipulation functions by itself, but itself tries to make it as easy as possible to share data with third-party libraries that provide these functions.
For example, with the following C# code you can rotate the images in the sink using OpenCV (using the ic4dotnet.OpenCvSharp
interop assembly and OpenCvSharp):
var sink = new ic4.QueueSink();
var pool = new ic4.BufferPool();
sink.FramesQueued += (object? sender, ic4.QueueSinkEventArgs e) =>
{
while (e.Sink.TryPopOutputBuffer(out var buffer))
{
var rotatedType = new ic4.ImageType(buffer.ImageType.Height, buffer.ImageType.Width, buffer.ImageType.PixelFormat);
var rotatedBuffer = pool.GetBuffer(rotatedType);
var bufferView = buffer.CreateOpenCvWrap();
var rotatedView = rotatedBuffer.CreateOpenCvWrap();
Cv2.Rotate(bufferView, rotatedView, RotateFlags.Rotate90Clockwise);
display.DisplayBuffer(rotatedBuffer);
buffer.Dispose();
rotatedBuffer.Dispose();
}
};
grabber.StreamSetup(sink);
This starts a data stream from grabber
and manually displays the rotated images in display
.
(Please note that it will only work this way if the device's PixelFormat is something like Mono8 or BGR8. For bayer formats, you will have to declare a transposed bayer pattern as pixel format in the destination buffer.)
I see, cheers for the swift reply !
Hi,
I was wondering if there existed an option to rotate the image displayed on the camera ? I've noticed a possibility to flip the image, but not for rotation. I recall IC Capture had this option.
Or are we perhaps meant to manipulate the ImageBuffer to rotate the image ?
Thanks for the help if we may asks questions here.