I’m trying to capture images from a Webcam in a WinUI3 app.
After some trial and error, I finally managed to do so via MediaFrameReader.
Now I’ve got the captured images as SoftwareBitmap and as I’d like to feed these images to OCR, I need to rotate them.
I’ve already tried several ways to rotate the images:
- MediaCapture.SetPreviewRotation does not seem to work with MediaFrameReader (and I haven’t found any way to use the VideoPreview stream to capture images without having a CameraPreview control attached as sink)
- Setting it via MediaCapture.SetEncodingPropertiesAsync also doesn’t seem to work (might also only work when you’re using the VideoPreview stream)
- Rotating the SoftwareBitmap itself, by converting it to a PNG or BMP stream with BitmapEncoder and a BitmapTransform.Rotation set and decoding it with BitmapDecoder. This results in a correctly rotated image with the right dimension, but completely black
Note: I don’t want to display the image rotated, so RenderTransform/LayoutTransform in my apps Xaml are not what I’m looking for here.
New contributor
Tobias is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.