MaxstARSDK  3.5.0
MasCameraDevice.mm
1 //
2 // MasCameraDevice.m
3 // MaxstAR
4 //
5 // Created by Kimseunglee on 2017. 11. 23..
6 // Copyright © 2017년 Maxst. All rights reserved.
7 //
8 
9 #import "MasCameraDevice.h"
10 #import "CameraDevice.h"
11 #import "MasMatrixUtil.h"
12 #include <string>
13 #include <list>
14 #import <simd/SIMD.h>
15 
16 @interface MasCameraDevice()
17 {
18  maxstAR::CameraDevice *cameraDevice;
19 }
20 
21 @end
22 
23 @implementation MasCameraDevice
24 
25 - (instancetype)init {
26  self = [super init];
27  if (self) {
28  cameraDevice = maxstAR::CameraDevice::getInstance();
29  }
30  return self;
31 }
32 
33 - (MasResultCode) start:(int) cameraId width:(int) width height:(int) height {
34  return (MasResultCode)cameraDevice->start(cameraId, width, height);
35 }
36 - (void) stop {
37  cameraDevice->stop();
38 }
39 - (int) getWidth {
40  return cameraDevice->getWidth();
41 }
42 - (int) getHeight {
43  return cameraDevice->getHeight();
44 }
45 - (bool) setFocusMode:(MasFocusMode) mode {
46  return cameraDevice->setFocusMode((maxstAR::CameraDevice::FocusMode)mode);
47 }
48 - (bool) setFlashLightMode:(bool) toggle {
49  return cameraDevice->setFlashLightMode(toggle);
50 }
51 - (bool) setAutoWhiteBalanceLock:(bool) toggle {
52  return cameraDevice->setAutoWhiteBalanceLock(toggle);
53 }
54 - (void) flipVideo:(MasFlipDirection) direction toggle:(bool) toggle {
55  cameraDevice->flipVideo((maxstAR::CameraDevice::FlipDirection)direction, toggle);
56 }
57 
58 - (NSMutableArray*) getParamList {
59  NSMutableArray *returnArray = [[NSMutableArray alloc] init];
60  std::list<std::string> paramlist = cameraDevice->getParamList();
61  for (std::string eachParam : paramlist) {
62  NSString *eachNSString = [NSString stringWithCString:eachParam.c_str() encoding:NSUTF8StringEncoding];
63  [returnArray addObject:eachNSString];
64  }
65 
66  return returnArray;
67 }
68 - (bool) setParam:(NSString*) key toggle:(bool) toggle {
69  std::string keyString = std::string([key UTF8String]);
70  return cameraDevice->setParam(keyString, toggle);
71 }
72 - (bool) setParam:(NSString*) key value:(int) value {
73  std::string keyString = std::string([key UTF8String]);
74  return cameraDevice->setParam(keyString, value);
75 }
76 - (bool) setParam:(NSString*) key min:(int) min max:(int) max {
77  std::string keyString = std::string([key UTF8String]);
78  return cameraDevice->setParam(keyString, min, max);
79 }
80 - (bool) setParam:(NSString*) key valueString:(NSString*) value {
81  std::string keyString = std::string([key UTF8String]);
82  std::string valueString = std::string([value UTF8String]);
83  return cameraDevice->setParam(keyString, valueString);
84 }
85 - (void) setNewFrame:(Byte *) data length:(int) length width:(int) width height:(int) height format:(MasColorFormat) format {
86  cameraDevice->setNewFrame(data, length, width, height, (maxstAR::ColorFormat)format);
87 }
88 - (matrix_float4x4) getProjectionMatrix {
89  matrix_float4x4 returnMatrix = [MasMatrixUtil makeMatrix:(float*)cameraDevice->getProjectionMatrix()];
90  return returnMatrix;
91 }
93  matrix_float4x4 returnMatrix = [MasMatrixUtil makeMatrix:(float*)cameraDevice->getBackgroundPlaneProjectionMatrix()];
94  return returnMatrix;
95 }
96 
97 @end
matrix_float4x4 getBackgroundPlaneProjectionMatrix()
Get projection matrix for background plane rendering.
void stop()
Stop camera preview.
class for camera device handling
NSMutableArray * getParamList()
Get supported parameter key list.
matrix_float4x4 getProjectionMatrix()
Get projection matrix. This is used for augmented objects projection and background rendering...