Community

Topic: iOS SDK

Black Screen camera (SOLVED)

Antonio Mazzeo
Sunday, February 19, 2017

Hi to everyone.
I'm starting to try your iOS sdk and i have a problem to create a simple test project. I'm reading your tutorial (probably written for swift 2) and i'm able to compile and install my test project, but, after i agree privacy alert for camera use, i see only a blank black image. Log shows "startCameraSampligWithCompletionHandler called with session...". I'm using Xcode 8.2.1 (last version) and swift 3. Thanks in advance.

user profile image
Support Team  (expert)
Tuesday, February 21, 2017

Hi Antonio,
Pikkart iOS tutorials have been written using swift 2.3 .
If you want to execute them using Xcode 8.2.1 you could check if "Use Legacy Swift Language Version" build setting is set to "Yes".
This allow Xcode to compile tutorials using older swift versions.

That said, we are working to upgrade Pikkart iOS tutorial to latest swift version, which will be available in few weeks.

Jamie Lemon
Wednesday, November 22, 2017

I get exactly this problem with your latest SDK and following the "Getting Started" guide.
With this the last log I get is:
startCameraSamplingWithCompletionHandler called with session 0x1c0008690
With your sample Xcode project I get:
startCameraSamplingWithCompletionHandler called with session 0x1c0007170
CameraRenderer::UpdateRendering 00 w 640.000000 h 480.000000 w1 640.000000 h1 480.000000CameraRenderer::UpdateRendering 01 1.000000 0.000000 0.000000 0.000000CameraRenderer::UpdateRendering 02 0.000000 1.000000 0.000000 0.000000CameraRenderer::UpdateRendering 03 0.000000 0.000000 -0.020202 -1.002002CameraRenderer::UpdateRendering 04 0.000000 0.000000 0.000000 1.000000

So basically the CameraRenderer isn't starting for whatever reason.
Can I send you my Xcode project?

Jamie Lemon
Wednesday, November 22, 2017

Okay - I "solved" it.
It seems like I need to add the following methods to my ViewController:

internal func updateViewPortWithOrientation() {

let orientation:UIInterfaceOrientation = UIApplication.shared.statusBarOrientation
let mainScreen:UIScreen=UIScreen.main
let boundScreen:CGRect=mainScreen.bounds
let scale:CGFloat=mainScreen.scale
var widthPort:CGFloat=boundScreen.size.width*scale;
var heightPort:CGFloat=boundScreen.size.height*scale;

if (scale == 3) // iPhone 6 plus non è un vero @3x, ma c'e' un downsampling
// http://www.paintcodeapp.com/news/iphone-6-screens-demystified
{
widthPort=widthPort/1.15;
heightPort=heightPort/1.15;
}

var angle:Int=90;

switch (orientation) {
case .portrait:
angle=90
case .landscapeRight:
angle=0
case .landscapeLeft:
angle=180
case .portraitUpsideDown:
angle=270
default:
break
}
self.UpdateViewPortWithSize(CGSize(width: widthPort,height: heightPort), angle: angle)
}

internal func UpdateViewPortWithSize(_ size:CGSize, angle:Int) {
_ViewportWidth = size.width;
_ViewportHeight = size.height;
_Angle = angle;
}

override func glkView(_ view: GLKView, drawIn rect: CGRect) {

if (!self.isActive()) {
return
}

glClear(GLbitfield(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));

self.renderCamera(withViewPortSize: CGSize(width: _ViewportWidth, height: _ViewportHeight), andAngle: Int32(_Angle))

glFinish();
}

I think your Getting Started Guide needs another re-write or you include these funcs in your base PKTCameraController class. I guess at there moment for people following the Getting Started guide they end up with a project which has no viewport width or height and no camera render!

Sign in to add a comment