protected override void DoEnable() { if (enabled_) { return; } if (smartInitFailed_) { return; } if (self_ == IntPtr.Zero) { return; } // Create CameraDevice cameraDevice_ = new smartar.CameraDevice(smart_, cameraDeviceSettings.cameraId, forceOldAndroidCameraAPI_); cameraDevice_.GetRotation(out cameraRotation_); int frontCameraId; smartar.CameraDevice.GetDefaultCameraId(smart_, smartar.Facing.FACING_FRONT, out frontCameraId, forceOldAndroidCameraAPI_); isFront_ = frontCameraId != smartar.CameraDevice.INVALID_CAMERA_ID && cameraDeviceSettings.cameraId == frontCameraId; #if UNITY_ANDROID && !UNITY_EDITOR // get camera hw support int apiLevel = 0; int feature = -1; androidCameraFeature.androidCanUseNewAPI_ = cameraDevice_.IsAndroidCamera2Available(smart_, isFront_, out apiLevel, out feature); cameraDevice_.GetAndroidCameraAPIFeature(out apiLevel, out feature); androidCameraFeature.androidCameraApiLevel_ = apiLevel; androidCameraFeature.androidCameraHwFeature_ = feature; #endif if (cameraDeviceSettings.videoImageSize.x != 0 && cameraDeviceSettings.videoImageSize.y != 0) { cameraDevice_.SetVideoImageSize((int)cameraDeviceSettings.videoImageSize.x, (int)cameraDeviceSettings.videoImageSize.y); } ConfigCameraDevice(cameraDeviceSettings, true); isFlipX_ = false; isFlipY_ = false; if (isFront_) { #if UNITY_IOS && !UNITY_EDITOR isFlipY_ = true; #elif UNITY_EDITOR || UNITY_STANDALONE_WIN // NOOP #else if (cameraRotation_ == smartar.Rotation.ROTATION_0 || cameraRotation_ == smartar.Rotation.ROTATION_90) { isFlipX_ = true; } else { isFlipY_ = true; } #endif } cameraImageDrawer_.SetFlipX(isFlipX_); cameraImageDrawer_.SetFlipY(isFlipY_); // Setup Recognizer smartar.CameraDeviceInfo cameraInfo = new smartar.CameraDeviceInfo(); cameraDevice_.GetDeviceInfo(cameraInfo); recognizer_.SetCameraDeviceInfo(cameraInfo); // Enable native instance sarSmartar_SarSmartARController_sarDoEnable(self_, cameraDevice_.self_); // set listener cameraDevice_.SetStillImageListener(new StillImageListener(createCaptureImagePath(), smart_)); cameraDevice_.SetAutoFocusListener(new AutoFocusListener()); cameraDevice_.SetAutoExposureListener(new AutoExposureListener()); cameraDevice_.SetAutoWhiteBalanceListener(new AutoWhiteBalanceListener()); // Start components cameraImageDrawer_.Start(); landmarkDrawer_.Start(); cameraDevice_.Start(); sensorDevice_.Start(); if (GetComponent <Camera>().clearFlags != CameraClearFlags.Depth && GetComponent <Camera>().clearFlags != CameraClearFlags.Nothing) { GetComponent <Camera>().clearFlags = CameraClearFlags.Depth; } enabled_ = true; }
public int GetDeviceInfo(CameraDeviceInfo info) { return(sarSmartar_SarCameraDevice_sarGetDeviceInfo(self_, info.self_)); }
//--------------------------------------------------------------- // setting public int SetCameraDeviceInfo(CameraDeviceInfo info) { return(sarSmartar_SarRecognizer_sarSetCameraDeviceInfo(self_, info.self_)); }