当我尝试编译代码时,Android Studio 3.0.1上会出现以下错误
Error:Program type already present: com.squareup.picasso.Action$RequestWeakReference
Run Code Online (Sandbox Code Playgroud)
我的gradle代码:
...
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'com.google.gms:google-services:3.1.0'
compile 'com.google.android.gms:play-services:11.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
如何修复我的gradle脚本以修复错误?
在横向,我使用myImageView.setImageBitmap(myBitmap)和使用ontouch侦听器,以getX及getY和调整的位置myImageView(同getRawX和getRawY).然后bitmapToMat,我使用构建MAT来使用OpenCV更多地处理图像.我找到了两个调整大小的场景,其中onTouch位置将在我触摸的位置绘制一个圆圈,但有时位置将位于Mat之外并导致NPE并在处理期间失败.
场景1: resize(myImageView.getWidth(), myImageView.getHeight())
场景2:resize(myImageView.getHeight(), myImageView.getWidth())和
x = x(myImage.getHeight()/myImageView.getWidth())
y = y(myImage.getWidth()/myImageView.getHeight())
Run Code Online (Sandbox Code Playgroud)
如果我不改变x,我可以点击NPE图像中的任何地方,但画出的圆圈远不在我触摸的地方.
处理后我matToBitmap(myMAT, newBitmap) 和myImageView.setImageBitmap(newBitmap).
我显然错过了一些东西,但有没有一个简单的方法来获得触摸位置并在MAT中使用该位置?任何帮助都是极好的!