How to find the object length using camera in android - android

i want to find the object length using camera . I have search a lot and i have found
relation between distance & view angle.
Formula angle= arctan(d/2f)
but i m frustrated and not find any relative code. so please suggest me the working
code in order to find the object height using camera. if distance from the object is
know then how to find the object length
Thanks in advance

verticalViewAngleDegrees = myCamera.getParameters().getVerticalViewAngle();
heightOfObjectFillingImage = 2 * userSpecifiedDistance * tan(toRadians(verticalViewAngleDegrees/2));
approxHeightOfObject = verticalPixelsOfObject / verticalPixelsOfWholeImage * heightOfObjectFillingImage;
I'm not confident that the trigonometry is the best that I could do, but that is a first approximation.

Related

android calculate rise over run from angle

We are trying to calculate the rise over the run of an object. We know the angle of a right triangle and we know the run. When we use the scientific Microsoft calculator we get the tangent of the angle and multiply by the run to get the rise.
angle = 7.5 tangent = 0.1316 in degrees multiply by run and ans 1.579 From this we now know how to set the X and Y coordinates of the Imageview object
We have seen all types of answers about how to do this with Java for Android none of which give the results based on the use of the MS calculator. We tried this
float T = (float) toRadians(tan(7.5));
Not even close we also tried toDegrees
So the we have two questions
How to calculate the rise knowing the run and the angle?
Is there a better way to set the X and Y value of the object so it will follow a path on a desired angle?
tan(angle) = rise/run. what you need is to rearrange this.
rise = tan(angle) * run
In PHP this is accomplished like this:
$rise = tan(deg2rad($degrees)) * $distance;
It took me a while to figure out that PHP's tan() function expects the angle to be in radians, so I had to convert to that first.
I know that's not an Android-specific response, but I'm leaving it here anyway in case it saves someone else some time.

Android How to get extrapolated value in an androidplot curve using SplineLineAndPointFormatter

I try to find the extrapolated Y value of a point on a androidplot curve.
For example, I have three points in a array: A (0; 0) B (15; 5) C (30; 0).
I displayed in androidplot with smoothing using SplineLineAndPointFormatter.
How can we do to find the Y value of the point N(10; ?)
Look at the example image
Thanks for any help in advance.
First off, you should not use that interpolation method because it uses cubic beziers and will plot false data. I posted a full answer in the linked question back in 2014.
Instead you should use the CatmullRomInterpolator. Once you've switched over to that, you can retrieve the interpolated series by invoking CatmullRomInterpolator.interpolate(XYSeries, Params). You can then retrieve N directly from the interpolated series.

How to find nearest police station to a geo point

How can you find a particular area's police station nearest to a Geo point in android? I set types = type of place to search types = "police"; but no results were found. However, when I set types = "pharmacy";,types = "hospital"; it works properly. i have use this tutorial. Does anyone have any ideas about this?
the project you are referring to is working just perfectly. The Only possible solution I can come up with is that 'there may be no 'POLICE STATION', within the give radius. Try increasing the radius, in the above sample;
change this:
double radius = 1000;
which come under the LoadPlaces AsyncTask.

GPS route length estimate, accounting for uncertainty of positions

So, this is a common problem in apps that track your location over a journey (a run or cycle workout, for example).
Clearly GPS navigators have less trouble, since they can assume you snap to a point on a road - however, if you're running in the park, snapping to some road grid is going to give you totally crazy numbers.
The problem as far as I see it is to combine the great-circle distances between the waypoints, but taking into account the errors (accuracy values) such that you don't veer off course too far for a low-accuracy point. The rough implementation in my head involves plotting some bezier curve (using the velocity/bearing at the point to add spline direction and weight) and integrating over it.
However, clearly this is something people have sovled before. Anyone know of the implementations, or are they all buried in proprietary software?
Bonus points for anyone who can also use the (mostly) less accurate cell tower points (which come with different/out-of-sync timestamps, and no velocity or bearing information).
The eventual implementation will be in javascript or python, whichever is faster (I'm using SL4A,) but I'm looking for general algorithms here.
To get everyone started, here is the naive algorithm, not using any velocity or bearing info.
The arc length s is calculable from the two (long, lat) pairs (the start and end waypoints) of the segment we'll start with, by the standard formula.
Assuming we've converted the value pairs into standard spherical coordinates phi and theta (here as arrays, so using phi[0] and phi[1] for locations 0 and 1) in radians, the arc length is just:
from math import sin, cos, arccos, sqrt
s = arccos(
sin(phi[0]) * sin(phi[1]) * cos(theta[0] - theta[1]) +
cos(phi[0]) * cos(phi[1])
)
However, since we've got a massive horrid function, we need to use the chain rule to work out the first order errors, and we get the following monster for delta_s:
delta_s = (1.0 / abs(sin(s))) * (
delta_phi[0] * abs(
sin(phi[0]) * cos(phi[1]) -
cos(phi[0]) * sin(phi[1]) * cos(theta[0] - theta[1])
) +
delta_phi[1] * abs(
sin(phi[1]) * cos(phi[0]) -
cos(phi[1]) * sin(phi[0]) * cos(theta[0] - theta[1])
) +
(delta_theta[0] + delta_theta[1]) * abs(
sin(phi[0]) * sin(phi[1]) * sin(theta[0] - theta[1])
)
)
We perform this operation on every pair of successive points in order, sum the ss, add the errors in quadrature as normal:
accumulator = 0.0
for error in errors:
accumulator += error * error
journey_error = sqrt(accumulator)
and thus, we know the uncertainty on our rubbish distance estimate. (we can even keep the accumulator around to speed up the calculation if we add a few points on the end - as we could in practise with real time data.)
However, this is going to give us huge errors, and only a very fuzzy idea of how far we've actually gone. This can't be how actual GPS equipment estimates distances, as it would never be accurate enough unless it had amazing signal all the time:
What we need is some more nuanced path approximation, which only bends the path out of position for the type of inaccurate points shown, rather than diverting it completely and massively increasing the distance estimate — in asking the question I was hoping to find out how all the existing implementations (probably) do it!

convert wgs 84 to lat/long

Hi
I am having a little trouble figuring out how to convert between types of coordinates. I have a list of coordinate sets with the following description
"Coordinates are always in the WGS84 system. All coordinates a represented as integer
values x and y where the coordinate value is multiplied with 1,000,000."
An example:
559262 6319512
Well, I need to convert these to long/lat (and back) so i can use these in google maps (android). But this is not as easy as it seams. I have been searching around and did find some code to do this, but it does not seam to work properly. Anyone who can provide some code for doing this? If possible, I would like to avoid a big geo framework (it has to be used in an android application).
thanks.
best regards, kenneth
EDIT:
I did find a solution on my own. I downloaded the class described here:
http://www.ibm.com/developerworks/java/library/j-coordconvert/
And it works fine. Hope someone can find it useful.
I am sorry for posting before having done my homework decently. Thanks to everyone who posted
If you're getting the location from the GPS on android, you will get a Location object that holds Lat/Long as doubles. In order to display a point on Google Maps, you need to turn these double values into a GeoPoint object using:
GeoPoint location = new GeoPoint(
(int) (mLocation.getLatitude()) * 1E6),
(int) (mLocation.getLongitude()) * 1E6)
);
Hope thats helpful.
All GPS systems give their latitude and longitude with respect to the WGS84 model of the Earth. Unless you intend to give the lat/lon with respect to a nation's local model, such as the British OSGB36 model, you should be fine treating the coordinates you have as representing microdegrees. Even here in the Britain, the Admiralty now print their nautical charts with lat/lon relative to WGS84, I expect the Ordnance Survey land maps will follow suit soon, if they haven't already done so.

Categories

Resources