ImageView无论设备大小如何,我都希望获得坐标.
有没有办法!!
我曾尝试为其创建特定尺寸ImageView,即使是特定尺寸Parent View,但它不起作用.
我尝试了以下可能的方法.
int[] posXY = new int[2];
imageview.getLocationOnScreen(posXY);
int MoveX = posXY[0];
int MoveY = posXY[1];
Run Code Online (Sandbox Code Playgroud)
我也尝试过Matrix,但没有工作.
Matrix m = imageview.getImageMatrix();
Run Code Online (Sandbox Code Playgroud)
尝试下面的代码,但它也无法正常工作.!!
我需要为同一点(位置)的所有设备获得相同的{x,y}坐标.
final float[] getPointerCoords(ImageView view, MotionEvent e)
{
final int index = e.getActionIndex();
final float[] coords = new float[] {
e.getX(index), e.getY(index)
};
Matrix matrix = new Matrix();
view.getImageMatrix().invert(matrix);
matrix.mapPoints(coords);
return coords;
}
Run Code Online (Sandbox Code Playgroud)
这是绘制方法:
如果我在绘图中设置位图图像,则它不适合每个设备的屏幕.如果我设置显示宽度和高度的图像,我会得到不同的坐标.
@Override
public void draw(Canvas canvas) {
// TODO Auto-generated method stub
super.draw(canvas);
Resources res = …Run Code Online (Sandbox Code Playgroud) <script type="text/javascript" charset="utf-8">
var pictureSource; // Picture source
var destinationType; // Sets the format of returned value
// Wait for PhoneGap to connect with the device
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready to be used!
function onDeviceReady()
{
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
function capturePhoto() {
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 25, destinationType:
Camera.DestinationType.FILE_URI });
}
function onPhotoURISuccess(imageURI) {
createFileEntry(imageURI);
}
function createFileEntry(imageURI) {
window.resolveLocalFileSystemURI(imageURI, copyPhoto, fail);
}
function copyPhoto(fileEntry) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
fileSys.root.getDirectory("photos", {create: true, …Run Code Online (Sandbox Code Playgroud) 我想找到解决方案来获取使用相机的对象的尺寸,它听起来像复制一个
但解决方案并没有帮助我.从上面链接我有一个想法找出距离(测量距离).
有人可以建议我如何获得物体的宽度和高度.简单的数学或任何想法将是非常有帮助的.
有没有可能使用OpenCV实现上述解决方案. 测量高度和宽度
到目前为止我尝试了什么:
假设我们假设固定距离,我们可以计算仰角
tan(?/2) = (l/2)/d,
hence
? = 2*atan(l/2d)
Run Code Online (Sandbox Code Playgroud)
但是我们仍然不知道L的值(物体的长度)
查找视角的另一种方法:
double thetaV = Math.toRadians(camera.getParameters().getVerticalViewAngle());
double thetaH = Math.toRadians(camera.getParameters().getHorizontalViewAngle());
Run Code Online (Sandbox Code Playgroud)
似乎不起作用!!