我试图在android中实现两个手指旋转,但它并没有按预期工作.目标是实现像Google Earth一样的旋转(双指旋转焦点周围的图像).目前我的旋转侦听器如下所示:
private class RotationGestureListener {
private static final int INVALID_POINTER_ID = -1;
private float fX, fY, sX, sY, focalX, focalY;
private int ptrID1, ptrID2;
public RotationGestureListener(){
ptrID1 = INVALID_POINTER_ID;
ptrID2 = INVALID_POINTER_ID;
}
public boolean onTouchEvent(MotionEvent event){
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
sX = event.getX();
sY = event.getY();
ptrID1 = event.getPointerId(0);
break;
case MotionEvent.ACTION_POINTER_DOWN:
fX = event.getX();
fY = event.getY();
focalX = getMidpoint(fX, sX);
focalY = getMidpoint(fY, sY);
ptrID2 = event.getPointerId(event.getActionIndex());
break;
case MotionEvent.ACTION_MOVE:
if(ptrID1 != INVALID_POINTER_ID && ptrID2 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用常规网络摄像头确定骨架关节(或者至少能够跟踪单个手掌).我在网上看了一遍,似乎无法找到办法.
我发现的每个例子都是使用Kinect.我想使用一个网络摄像头.
我不需要计算关节的深度 - 我只需要能够识别它们在框架中的X,Y位置.这就是我使用网络摄像头而不是Kinect的原因.
到目前为止,我已经看过了:
我正在寻找一个C/C++库(但此时会查看任何其他语言),最好是开源(但同样,会考虑任何许可),可以执行以下操作:
如果有人可以帮我解决这个问题,我将非常感激.我已经被困在这几天了,没有明确的道路可以继续.
UPDATE
2年后,找到了一个解决方案:http://dlib.net/imaging.html#shape_predictor
您将如何设置手势识别器,以便您可以同时使用UISwipeGestureRecognizer和UIPanGestureRecognizer?这样,如果您快速触摸并快速移动(快速滑动),它会将手势检测为滑动,但如果您触摸然后移动(触摸和移动之间的短暂延迟),它会将其检测为平移?
我已经尝试了requireGestureRecognizerToFail的各种排列,并且没有完全帮助,它使得如果离开SwipeGesture然后我的平移手势将向上,向下和向右工作但是滑动手势检测到任何左移动.
我正在尝试在Android中实现OnGestureListener.
我的布局中有三个TextView.
我想要实现的是为两个textView设置Gesture Listener.
这是布局 -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvOne"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="One" />
<TextView
android:id="@+id/tvTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvOne"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Two" />
<TextView
android:id="@+id/tvThree"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTwo"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Three" />
Run Code Online (Sandbox Code Playgroud)
这是活动 -
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
public class TimeActivity extends Activity implements OnGestureListener {
GestureDetector gestureScanner;
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wheelview);
gestureScanner …Run Code Online (Sandbox Code Playgroud) 如果我将一个手势识别器添加到一个名为的表格单元格cell,例如:
UILongPressGestureRecognizer *_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellGestureRecognized:)];
_longPressRecognizer.allowableMovement = 20;
_longPressRecognizer.minimumPressDuration = 1.0f;
[cell addGestureRecognizer:_longPressRecognizer];
[_longPressRecognizer release], _longPressRecognizer = nil;
Run Code Online (Sandbox Code Playgroud)
我是否需要-removeGestureRecognizer:在某个时刻手动调用此单元格,或者在不再使用单元格时是否删除并释放手势识别器?
iphone memory-management gesture-recognition uigesturerecognizer
有手势相关的问题.我实现了UISwipeGestureRecognizer以获得向左和向右滑动事件,并且工作正常.然而,我面临的问题是我在同一视图中的UISlider不是很好玩.滑块的滑动被误认为是向左/向右滑动.
以前有人遇到过这个问题,有什么想法可以纠正吗?
非常感谢.
以下是视图控制器中包含的代码:
- (void)viewDidLoad {
[super viewDidLoad];
//Setup handling of LEFT and RIGHT swipes
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
}
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
NSLog(@"Swipe Right");
//Do stuff
}
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"Swipe Left");
//Do stuff
}
}
Run Code Online (Sandbox Code Playgroud) iphone event-handling gesture-recognition uislider uigesturerecognizer
我想实现以下目标:
我希望用户能够使用陀螺仪"记录"iPhone的运动.之后,用户应该能够复制相同的动作.我使用以下方法提取俯仰,滚转和偏航:
[self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMDeviceMotion *motion, NSError *error)
{
CMAttitude *attitude = motion.attitude;
NSLog(@"pitch: %f, roll: %f, yaw: %f]", attitude.pitch, attitude.roll, attitude.yaw);
}];
Run Code Online (Sandbox Code Playgroud)
我想如果用户处于记录模式,我可以将这些值存储到数组中.当用户尝试复制该移动时,我可以将复制的移动阵列与录制的移动阵列进行比较.问题是,如何以智能方式比较两个阵列?它们永远不会具有完全相同的值,但它们可能有些相同.
我在这里走在正确的轨道上吗?
更新:我想也许Alis回答有关使用DTW的方法对我来说可能是正确的方法.但是我并不那么聪明(显然),所以如果有人能帮助我完成与阵列比较的第一步,我会是一个快乐的人!
谢谢!
iphone math android artificial-intelligence gesture-recognition
我正在尝试使用Android的手势监听器和缩放监听器来实现缩放和拖动.问题是,当我执行捏拉缩放时,图像(我正在尝试缩放)反弹到特定位置.变焦位置也不居中.以下代码演示了我想要实现的目标.知道为什么图像跳跃(以及如何纠正)?
public class CustomView extends View {
Bitmap image;
int screenHeight;
int screenWidth;
Paint paint;
GestureDetector gestures;
ScaleGestureDetector scaleGesture;
float scale = 1.0f;
float horizontalOffset, verticalOffset;
int NORMAL = 0;
int ZOOM = 1;
int DRAG = 2;
boolean isScaling = false;
float touchX, touchY;
int mode = NORMAL;
public CustomView(Context context) {
super(context);
//initializing variables
image = BitmapFactory.decodeResource(getResources(),
R.drawable.image_name);
//This is a full screen view
screenWidth = getResources().getDisplayMetrics().widthPixels;
screenHeight = getResources().getDisplayMetrics().heightPixels;
paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
paint.setColor(Color.WHITE); …Run Code Online (Sandbox Code Playgroud) android image-processing gesture-recognition android-view pinchzoom
我需要检测我的滑动手势的方向,我有问题.手势正在工作,但我不知道如何检测方向....
swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(detectSwipe:)];
[swipeGesture setNumberOfTouchesRequired:1];
[swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionUp];
[appView addGestureRecognizer:swipeGesture];
-(void)detectSwipe:(UISwipeGestureRecognizer *)recognizer {
switch (recognizer.direction) {
case UISwipeGestureRecognizerDirectionUp:
NSLog(@"smth1");
break;
case UISwipeGestureRecognizerDirectionDown:
NSLog(@"smth2");
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
它不起作用:/
objective-c gesture-recognition swipe ios uiswipegesturerecognizer
我的目标是识别安装在太阳光点上的加速度计的简单手势.手势可以像旋转设备或以几种不同的动作移动设备一样简单.该设备目前只有加速度计,但我们正在考虑增加陀螺仪,如果它更容易/更准确.
有没有人有如何做到这一点的建议?Java中的任何可用库?您推荐的示例项目我结账了吗?你推荐的论文?
sun spot是一个Java平台,可帮助您快速制作系统原型.它使用Java编程,可以将命令转发回连接到计算机的基站.如果我需要解释硬件如何工作更多留下评论.