我需要旋转一个有一些按钮的视图。随着手指的移动,视图也应该相应地随着它的子视图旋转。
到目前为止,我已经实现了这一点:
private RelativeLayout mCircle;
private double mCurrAngle = 0;
private double mPrevAngle = 0;
int i = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mCircle = (RelativeLayout) findViewById(R.id.circle);
mCircle.setOnTouchListener(this); // Your activity should implement
// OnTouchListener
}
@Override
public boolean onTouch(View v, MotionEvent event) {
final float xc = mCircle.getWidth() / 2;
final float yc = mCircle.getHeight() / 2;
final float x = event.getX();
final float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
mCircle.clearAnimation();
mCurrAngle …Run Code Online (Sandbox Code Playgroud) 有什么方法可以使用 OpenCV 和 Python 来拉直这个图像吗?我正在使用不同的转换来解决它,但我无法得到它。
这是我的代码:
rows, cols, h = img.shape
M = np.float32([[1, 0, 100], [0, 1, 50]])
Run Code Online (Sandbox Code Playgroud)
然后我应用仿射变换。
dst = cv2.warpAffine(roi, M, (cols, rows))
Run Code Online (Sandbox Code Playgroud)
我仍然无法获得所需的图像输出来拉直。现在挠我的头快一个小时了。任何人都可以帮助我吗?
opencv image-processing image-rotation affinetransform python-2.7
我在Matlab中有一个GUI(使用GUIDE),它的外观如下:

我想使用滑块旋转图像并实时显示更改.
我用轴来显示图像.
我怎样才能做到这一点?
编辑:我正在构建OCR应用程序.这就是当我旋转它时板看起来如何,数字完全变形.

谢谢.
我为我创建的网站http://sandbox.worldwatchlist.us创建了一个简单的旋转横幅.
一切都工作正常,直到我在浏览器中找到另一个标签然后几秒钟后回来......横幅每隔0.5秒或更短时间旋转一次.
我不知道为什么会发生这种情况,特别是因为我setTimeout在javascript中使用并将其设置为10秒(10000毫秒).
下面是服务器上banner.js文件中的所有代码.请指出任何可以解决这个问题的方法.您可以查看上面的网站,或者查看我在http://www.youtube.com/watch?v=HWb2uc6KpFM上截取的视频截图.每个浏览器都有我测试过的这个问题.
我已经到处寻找"jquery banner旋转太快"的答案,除了"使用setTimeout"之外没有解决我的问题的答案.
var banner_width = 960;
var default_pos = 0;
var current_pos = 0;
var next_pos;
var speed = 500;
var banner_tot; //number of banners
var current_num = 1; //current banner number
$(function(){
banner_tot = $(".banner_item").length;
$(".banner_slider").css({width:(banner_tot*banner_width)});
setTimeout( "slide()", 10000 );
});
function slide(){
if(current_num==(banner_tot)){
next_pos= 0;
$(".banner_slider").animate({left: next_pos}, speed);
current_num=1;
setTimeout( "slide()", 10000 );
}
else{
next_pos= current_num*(-banner_width);
$(".banner_slider").animate({left: next_pos}, speed);
current_num++;
setTimeout( "slide()", 10000 );
}
}
Run Code Online (Sandbox Code Playgroud) 我有简单的旋转变换,结合alpha,在第一次调用时效果很好,但第二次旋转不会发生(用户通过点击屏幕启动此动画).
这是我的基本动画功能:
- (void) animateMe:(UIImageView *)myImage delay:(NSTimeInterval)dly
{
[UIView animateWithDuration:1.0
delay:dly
options:UIViewAnimationOptionAutoreverse
animations:^(void){
myImage.alpha = 1.0;
myImage.transform = CGAffineTransformMakeRotation(180.0);
}
completion:^(BOOL finished) {
myImage.alpha = 0.0;
}];
}
Run Code Online (Sandbox Code Playgroud) 到目前为止,我有一个java应用程序,我绘制一个圆(播放器),然后在顶部(枪管)绘制一个绿色矩形.我有它,所以当玩家移动时,枪管随之而来.我想让它找到鼠标指向的位置,然后相应地旋转桶.我的意思是看看这个视频的一个例子我发现http://www.youtube.com/watch?v=8W7WSkQq5SU看看玩家图像在移动鼠标时的反应如何?
这是目前为止游戏的样子:

那我怎么像这样旋转呢?顺便说一句我不喜欢使用affinetransform或Graphics2D旋转.我希望有更好的方法.谢谢
我有一个问题,我使用相机意图捕获的图像被旋转,我问为什么使用相机意图捕获的图像在Android上的某些设备上旋转?
所以根据那里的建议答案,我现在正在尝试旋转使用相机获得的图像(我已经使用了相机意图).我的代码是,
public class SimpleCameraActivity extends Activity {
private static final int TAKE_PICTURE = 1888;
private Uri imageUri;
ImageView imageView;
Bitmap bitmap;
Button btnOK, btnDiscard;
RelativeLayout rLButtons;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_camera);
imageView = (ImageView) findViewById(R.id.image_view_sc);
captureImage();
}
public void captureImage() {
Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE");
File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
imageUri = Uri.fromFile(filePhoto);
MyApplicationGlobal.imageUri = imageUri.getPath();
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intentCamera, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) {
super.onActivityResult(requestCode, resultCode, …Run Code Online (Sandbox Code Playgroud) 目前我正在使用此代码(我在此处找到)在 Java 中旋转图像。代码运行良好,但我对旋转图像的质量不满意。
我该如何改进?它需要一个单独的库吗?
public static BufferedImage rotate(BufferedImage image, float angle) {
float radianAngle = (float) Math.toRadians(angle) ;
float sin = (float) Math.abs(Math.sin(radianAngle));
float cos = (float) Math.abs(Math.cos(radianAngle));
int w = image.getWidth() ;
int h = image.getHeight();
int neww = (int) Math.round(w * cos + h * sin);
int newh = (int) Math.round(h * cos + w * sin);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT);
Graphics2D …Run Code Online (Sandbox Code Playgroud) 这段代码是为了绘制塔.广场位置是广场的左上角.TILE_SIZE只是方形的尺寸.
SpriteBatch.Draw(TowerImage, new Rectangle(square.X * TILE_SIZE, square.Y * TILE_SIZE, TILE_SIZE, TILE_SIZE), null, Color.White, myTower.Rotation,
new Vector2(TILE_SIZE - 35, TILE_SIZE - 35), SpriteEffects.None, (float)0.0);
Run Code Online (Sandbox Code Playgroud)
这段代码是我确定旋转的方式
public void FaceTarget(Vector2 center, Vector2 enemyCenter)
{
Vector2 direction = center - enemyCenter;
direction.Normalize();
this.Rotation = (float)Math.Atan2(-direction.X, direction.Y);
}
Run Code Online (Sandbox Code Playgroud)
我这样做基于:
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Rotation.php
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Direction_to_Angle.php
旋转真的很奇怪,这是它看起来如何正常:

但是当它旋转时它会像这样:

最后,当它往下看时,它完全离开路径,它不是由它的中心旋转,但整个图像正在移动它为什么这样做?

只有第一张图像实际上是正确位置的塔
看起来它是左上角的旋转,我不知道为什么.有人可以帮忙吗?
我试图在Monogame中旋转一个精灵,但由于某种原因我无法正确!如果有人解释轮换之谜,我将非常感激!
这是我用来绘制和旋转我的精灵的代码行,只是注意变量y是我在每次更新时将其递增0.1的角度,这仅用于测试目的.如何让大炮围绕图像内的原点旋转?例如,它的中心点就像直升机螺旋桨?检查视频以查看此行代码的结果.
spriteBatch.Draw(cannon.image, new Rectangle(300, 300, cannon.image.Width, cannon.image.Height), null, Color.White, y, new Vector2(0, 0), SpriteEffects.None, 0f);
Run Code Online (Sandbox Code Playgroud) image-rotation ×10
rotation ×3
android ×2
animation ×2
c# ×2
image ×2
java ×2
monogame ×2
2d ×1
banner ×1
graphics2d ×1
ios5 ×1
javascript ×1
jquery ×1
matlab ×1
opencv ×1
python-2.7 ×1
slider ×1
sprite ×1
xna ×1