增强现实
我想在相机的图像上绘制该地点的引脚和信息。 请任何人帮助我.. 我已经在应用程序委托中完成了编码 代码是:-
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]; }
}
它显示相机。不是我想检测该位置并将图钉放在该位置上,以显示该位置的信息。
i want to draw the pin and information of the place on the image of the camera..
Please any one help me..
i had done the coding in the app delegate
The code is :-
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]; }
}
it shows the camera.Not i want to detect the place and put the pin on that place which shows the information of that place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一个更简单的方法来检测相机的存在:
恐怕 99% 的工作仍然在前面。大致您需要以下内容:
offset *(以像素为单位的宽度/水平视野)
以获得表示该点的标签的以像素为单位的偏移。对垂直偏移执行相同的操作。要定位标签,您可能需要使用 3D 引擎或将它们围绕设备旋转一圈(x=x+r*cos、y=y+r*sin)并使用广告牌效果。
如果这听起来工作量太大,请集中精力使用
偏移*像素宽度/水平视野
来实现对方位变化的响应。水平视野是相机的可视角度。对于人类来说是 180°,对于 iPhone 3 来说是 37.5°,那么对于 iPhone 4 来说是 45° 吗?宽度为 320,因此如果您与目标的距离为 10°,则必须将其水平移动到距中心 320*10/37.5 像素的位置。如果罗盘的读数有太多噪音,请添加低通滤波器。
Here is a more straightforward recipe to detect the presence of a camera:
99% of the job is still ahead I'm afraid. Roughly you need the following:
offset * (width in pixels / horizontal field vision)
to get the offset in pixels for the label representing the point. Do the same for the vertical offset.To position the labels you may want to use a 3D engine or rotate them in a circle around your device (x=x+r*cos, y=y+r*sin) and use a billboard effect.
If that sounds like too much work, concentrate on implementing just the response to changes in bearing using
offset * width in pixels / horizontal field vision
. Horizontal field vision is the visible angle for the camera. It is 180º for humans, 37.5 for iPhone 3, and hmm was it 45º for iPhone 4? Width is 320, so if you are looking 10º away from your target, you have to move it horizontally 320*10/37.5 pixels away from the center.If the readings from the compass have too much noise, add a low pass filter.
请访问
https://github.com/zac/iphonearkit。
这是可用的最好的 ObjectiveC 代码。
Please go through
https://github.com/zac/iphonearkit.
It's the best objectiveC code available.