android - 在 android 应用程序中运行 python 图像处理脚本

标签 android python opencv

我正在使用 python 脚本来检测使用 Hough 转换的圆圈,它导入“opencv2”和“math”库。我可以在 android 应用程序中运行这个脚本吗?如何做到这一点?以下应用程序是我想要运行的应用程序一个安卓应用程序。`import cv2
导入数学

def resizeImage(img):
    dst=cv2.resize(img,None,fx=1,fy=1,interpolation=cv2.INTER_LINEAR)
    return dst
img=cv2.imread('20140318_174800.jpg')
grey=cv2.imread('20140318_174800.jpg',0)
ret,thresh = cv2.threshold(grey,50,255,cv2.THRESH_BINARY)

circles = cv2.HoughCircles(thresh,cv2.cv.CV_HOUGH_GRADIENT,1,75,param1=50,param2=13,minRadius=0,maxRadius=400)
for i in circles[0,:]:
    #draw the outer circle
    cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
    #draw the centre of the circle
    cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)

##Determine co-ordinates for centre of circle
x1 = circles[0][0][0]
y1 = circles[0][0][1]
#x2 = circles[0][1][0]
#y2 = circles[0][1][1]
##Angle betwen two circles
#theta = math.degrees(math.atan((y2-y1)/(x2-x1)))

##print information
print "x1 = ",x1
print "y1 = ",y1
#print "x2 = ",x2
#print "y2 = ",y2

#print theta
print circles

##Resize image
img = resizeImage(img)
thresh = resizeImage(thresh)
##Show Images 
cv2.imshow("thresh",thresh)
cv2.imshow("img",img)

cv2.waitKey(0)

`

最佳答案

自动取款机,你不能。

您必须首先为 android 重新编译 cv2 模块,类似于 python4android 的方式(将系统调用重定向到 java rmi),这是一项艰巨的工作。

关于android - 在 android 应用程序中运行 python 图像处理脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23364720/

相关文章:

java - 如何在 Android Studio 中更新 Cordova 版本

android - 为什么 WebView 无法打开某些本地 URL(Android)?

python - 对于多输入模型,tf.data.Dataset.from_tensor_slices 的替代方案是什么?

c++ - 如何使用 C++ opencv 2.4.10 查找视频的帧率?

image-processing - 图像处理 - 哪种 OpenCV 算法适合我的需要?

javascript - 在android的 WebView 上隐藏网页的页脚

java - 我应该用对象类型为我的变量添加后缀吗?

python - 扩展 Django 用户模型后创建新用户

python 美汤,捡起所有元素

opencv - 对于什么样的应用程序,我可以使用 beagleboard 的 dsp 核心?我可以将 DSP 加速用于背景减法算法吗?