Reputation: 3473
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.
Upvotes: 3
Views: 1001
Reputation: 63667
Here is a more straightforward recipe to detect the presence of a camera:
BOOL isCameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
99% of the job is still ahead I'm afraid. Roughly you need the following:
Note that the distance in spherical geometry is calculated with the haversine formula, but the loss of precision is irrelevant for small distances if we assume cartesian coordinates, so we will just do that.
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.
Upvotes: 7
Reputation: 1050
Please go through
https://github.com/zac/iphonearkit.
It's the best objectiveC code available.
Upvotes: 1