Closed sayantan99 closed 4 years ago
Please post the full stack trace and the relevant section of your code.
The image is in the python folder of the app, along with the python file. Code:(Python) import cv2 from os.path import dirname, join from android.os import Environment def test(): src = cv2.imread("sam.jpg", 1 ) grayScale = cv2.cvtColor( src, cv2.COLOR_RGB2GRAY ) kernel = cv2.getStructuringElement(1,(17,17))
StackTrace: E/cv::error(): OpenCV(4.1.2) Error: Assertion failed (!_src.empty()) in cvtColor, file /home/smith/git/chaquo/python/server/pypi/packages/opencv-python/build/4.1.2.30/cp38-cp38-android_21_arm64_v8a/src/opencv/modules/imgproc/src/color.cpp, line 182 D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.chao, PID: 26627 com.chaquo.python.PyException: error: OpenCV(4.1.2) /home/smith/git/chaquo/python/server/pypi/packages/opencv-python/build/4.1.2.30/cp38-cp38-android_21_arm64_v8a/src/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
at <python>.ops.test(ops.py:12)
at <python>.chaquopy_java.call(chaquopy_java.pyx:281)
at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrows(chaquopy_java.pyx:253)
at com.chaquo.python.PyObject.callAttrThrows(Native Method)
at com.chaquo.python.PyObject.callAttr(PyObject.java:209)
at com.example.open.MainActivity$1.onClick(MainActivity.java:40)
at android.view.View.performClick(View.java:7870)
at android.widget.TextView.performClick(TextView.java:14970)
at android.view.View.performClickInternal(View.java:7839)
at android.view.View.access$3600(View.java:886)
at android.view.View$PerformClick.run(View.java:29363)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
As I already told you in #301, to open files in the same directory as the Python file you need to use the technique from #144.
com.chaquo.python.PyException: error: OpenCV(4.1.2) /home/smith/git/chaquo/python/server/pypi/packages/opencv-python/build/4.1.2.30/cp38-cp38-android_21_arm64_v8a/src/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'