ios*_*per 3 iphone augmented-reality
我想在相机的图像上绘制地方的引脚和信息..请任何人帮助我..我在应用程序委托中完成编码代码是: -
overlay = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; overlay.opaque = NO; overlay.backgroundColor=[UIColor clearColor];
[window addSubview:overlay];
#define CAMERA_TRANSFORM 1.24299
UIImagePickerController *uip;
@try {
uip = [[[UIImagePickerController alloc] init] autorelease];
uip.sourceType = UIImagePickerControllerSourceTypeCamera; uip.showsCameraControls = NO;
uip.toolbarHidden = YES;
uip.navigationBarHidden = YES;
uip.wantsFullScreenLayout = YES;
uip.cameraViewTransform = CGAffineTransformScale(uip.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);
}
@catch (NSException * e)
{ [uip release];
uip = nil;
}
@finally
{ if(uip) {
[overlay addSubview:[uip view]]; [overlay release]; }
}
Run Code Online (Sandbox Code Playgroud)
它显示了相机.我不想检测到这个地方并将针放在那个显示该地方信息的地方.
这是一个更直接的方法来检测相机的存在:
BOOL isCameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
Run Code Online (Sandbox Code Playgroud)
99%的工作仍然领先我害怕.大概你需要以下内容:
请注意,球面几何中的距离是使用半正公式计算的,但如果我们假设笛卡尔坐标,则精度损失与小距离无关,因此我们将这样做.
offset * (width in pixels / horizontal field vision)的偏移,则乘以获得表示该点的标签的偏移量(以像素为单位).对垂直偏移执行相同的操作.
要定位标签,您可能需要使用3D引擎或围绕设备旋转它们(x = x + r*cos,y = y + r*sin)并使用广告牌效果.
如果这听起来太多了,那就集中精力实施对轴承使用变化的响应offset * width in pixels / horizontal field vision.水平视野是摄像机的可见角度.人类为180º,iPhone 3为37.5,iPhone 4为45º?宽度为320,因此如果您距离目标10º,则必须将其水平移动距离中心320*10/37.5像素.
如果指南针的读数噪音太大,请添加低通滤波器.