Silence-GitHub / BBMetalImage

A high performance Swift library for GPU-accelerated image/video processing based on Metal.
MIT License
989 stars 126 forks source link

camera.switchCameraPosition() not working #16

Closed sebastianroth1 closed 4 years ago

sebastianroth1 commented 5 years ago

calling camera.switchCameraPosition() rotates .back camera instead of switching to .front camera

Silence-GitHub commented 5 years ago

Have you tried the demo project? In the view controller with camera, tap the metal view to switch camera. Does it work? If not, could you please provide the information about the device and iOS system (e.g. iPhone X iOS 13) ?

sebastianroth1 commented 5 years ago

The problem occurs on IOS 12.3 (iPhone 6) in the demo project. I will provide a test with IOS 13 and iPhone 11 later this week.

Silence-GitHub commented 5 years ago

I test iPhone 7 iOS 12.1, there is at least one rotated image frame. I will fix the problem. After the rotated image frame, the camera will switch (from back to front, or from front to back). So, in your iPhone 6 iOS 12.3, dose the camera switch?

sebastianroth1 commented 5 years ago

I need to correct myself. It is an iPhone 6 with IOS 12.1. Here the image rotates counterclockwise 90 degrees at the first click. Every further tip still shows the same rotated image. The front camera is not shown at all. Thank you!

Silence-GitHub commented 5 years ago

I don't have iPhone 6, but I maybe find the reason of the problem. According to iPhone 6 WikPedia, iPhone 6 front camera supports 1.2 MP (1280×960 px max.), dose not support 1920x1080. In the project demo, the camera session present is hd1920x1080, so it can not switch to front camera. The switchCameraPosition method should return false. You can print the result of the method to check it.

To work with iPhone 6, use default parameter to create camera.

camera = BBMetalCamera()
sebastianroth1 commented 5 years ago

As you recommended I changed camera = BBMetalCamera(sessionPreset: .hd1920x1080) to camera = BBMetalCamera(). Now the .front camera is activated and everything works as it should. The picture is no longer rotated and the front camera shows up on iPhone 6. Many thanks for your fast and expert help.