打开CV-无法执行具有cv2的python代码 [英] Open CV -unable to execute python code having cv2

查看:111
本文介绍了打开CV-无法执行具有cv2的python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CL-SOM-AM57x-TI AM5728 / AM5718模块化系统,并将其加载到基于Linux Debian的Ti矩阵应用启动器中。我正在尝试开发可从TI Matrix GUI启动的python应用程序。使用简单的python代码,该应用程序可以在终端中正常运行(加载并导入openCV和numpy),但是当我从TI矩阵GUI启动并运行该应用程序(已创建图标并正在执行该应用程序)时,该矩阵无法正常工作并显示一些错误/终端中的警告。该应用程序正在打开并在屏幕上显示值,但看起来像OpenCV模块,并且numpy无法加载或正常工作。

I'm using CL-SOM-AM57x - TI AM5728 / AM5718 System-on-Module and load it with Ti's matrix app launcher based on Linux Debian. I am trying to develop a python app which can be launched from TI Matrix GUI. With simple python code the app works fine in Terminal(loads and import openCV and numpy) but when I launch and run the App(have created Icon and the app is executing) from TI matrix GUI which doesn't work properly and shows some errors/warnings in terminal. The App is opening and Prints on screen values but it looks like the OpenCV module and numpy is not loading or working properly.

因此,问题是相同的代码适用于终端,但不是从TI矩阵GUI在App中启动时。

So the issue is that the same code works on Terminal but not when launched in an App from TI matrix GUI.

示例代码:

import numpy as np

import cv2

img = cv2.imread('rgb.jpg')

np_image = np.array(img)

num_list = np_image.tolist()

str1 =str(num_list)

print( len(str1))

print(str1)

Shell脚本
#!/ bin / bash

Shell script #!/bin/bash

/usr/bin/python2.7 /usr/share/matrix-gui-2.0/apps/ex_application/1.py

终端错误:


[6860.067644] omap_hwmod:mmu0_dsp2:_wait_target_disable失败

[ 6860.067644] omap_hwmod: mmu0_dsp2: _wait_target_disable failed

[6860.073549] omap-iommu 41501000.mmu:41501000.mmu:3.0版

[ 6860.073549] omap-iommu 41501000.mmu: 41501000.mmu: version 3.0

[6860.079683] oma p-iommu 41502000.mmu:41502000.mmu:3.0版

[ 6860.079683] omap-iommu 41502000.mmu: 41502000.mmu: version 3.0

[6860.093489] omap_hwmod:mmu0_dsp1:_wait_target_disable失败

[ 6860.093489] omap_hwmod: mmu0_dsp1: _wait_target_disable failed

[6860.099385] omap-iommu 40d01000.mmu:40d01000.mmu:3.0版

[ 6860.099385] omap-iommu 40d01000.mmu: 40d01000.mmu: version 3.0

[6860.105342] omap-iommu 40d02000.mmu:40d02000.mmu:3.0版

[ 6860.105342] omap-iommu 40d02000.mmu: 40d02000.mmu: version 3.0

[6870.136544] omap_hwmod:mmu1_dsp1:_wait_target_disable失败

[ 6870.136544] omap_hwmod: mmu1_dsp1: _wait_target_disable failed

[6870.149842] omap_hwmod:mmu0_dsp1:_wait_target_disable失败

[ 6870.149842] omap_hwmod: mmu0_dsp1: _wait_target_disable failed

[6870.163511] omap_hwmod:mmu1_dsp2:_wait_target_disable失败

[ 6870.163511] omap_hwmod: mmu1_dsp2: _wait_target_disable failed

[6870.176696] omap_hwmod:mmu0_dsp2:_wait_target_disable失败

[ 6870.176696] omap_hwmod: mmu0_dsp2: _wait_target_disable failed

应用程序的输出:

4
None

但是如果P在终端中运行相同的代码,则使用同一块板就可以正常工作并输出给出数组的矩阵。我需要在矩阵GUI中的一个应用程序上运行它,并希望获得与输出相同的数组。
有什么建议吗?

But if P run the same code in terminal, using the same board it works fine and output gives a matrix of array. I need to run this on an App in matrix GUI and would want to get the same Array as output. Any suggestions?

推荐答案

我找到了解决方案。
即使图像路径错误,也不会引发任何错误,但是print img不会给您任何结果。。openCV文档中提到了这一点。
所以我更改了行

I found the solution . "Even if the image path is wrong, it won’t throw any error, but print img will give you None".Which is mentioned in the openCV documentation . So i changed the line

img = cv2.imread('rgb.jpg')

img = cv2.imread('rgb.jpg')

img = cv2.imread('/ usr / share / matrix-gui-2.0 / apps / ex_application / rgb.jpg')

#输入完整目录

img = cv2.imread('/usr/share/matrix-gui-2.0/apps/ex_application/rgb.jpg')
#input full directory

这篇关于打开CV-无法执行具有cv2的python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆