chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
762 stars 130 forks source link

TypeError: only integer scalar arrays can be converted to a scalar index #376

Closed Charuwaka closed 3 years ago

Charuwaka commented 3 years ago

we have a python script which work fine in PC , but we run same script in android app we are getting above error. "TypeError: only integer scalar arrays can be converted to a scalar index" and its exactly failing at this line cv2.circle(mask, (cx, cy), radius -68, (255, 255, 255), thickness=-1)

mhsmith commented 3 years ago

I'm not familiar with this error, but there are many results for it on Google. Please have a look at them.

If you still can't work out the solution, please post the full stack trace.

Charuwaka commented 3 years ago

gone through almost like 20 forums question couldn't find a solution , problem is this is working perfectly in windows , but failing while running through. chacopy

mhsmith commented 3 years ago

Post the full stack trace please.

Charuwaka commented 3 years ago
com.chaquo.python.PyException: TypeError: only integer scalar arrays can be converted to a scalar index
    at <python>.detect_circle_window(circle_detect.py:141)
    at <python>.startcode.main(startcode.py:79)
    at <python>.chaquopy_java.call(chaquopy_java.pyx:285)
    at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrows(chaquopy_java.pyx:257)
    at com.chaquo.python.PyObject.callAttrThrows(Native Method)
    at com.chaquo.python.PyObject.callAttr(PyObject.java:209)

    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
mhsmith commented 3 years ago

I can't find any examples of this error being produced by cv2.circle. Are you absolutely certain that circle_detect.py line 141 is the line you posted? For example, is it possible that you edited the source code since the last time you rebuilt the app?

If you're sure this is the line causing the error, please add the following lines before it, and post the output they produce in the Logcat:

print(mask.shape, mask.dtype)
print(cx, cy, radius)

It might also be useful if you posted some of the other lines leading up to it.

Charuwaka commented 3 years ago

I/python.stdout: (1603, 2180) I/python.stdout:
I/python.stdout: uint8 I/python.stdout:
I/python.stdout: [979] I/python.stdout:
I/python.stdout: [950] I/python.stdout:
I/python.stdout: [450] I/python.stdout:

mhsmith commented 3 years ago

I think cx, cy and radius should be numbers, not lists.

Charuwaka commented 3 years ago

you mean [979] [950] ?

mhsmith commented 3 years ago

Yes, and [450]. They're printed with square brackets, so I think they must be lists. Check your code to see how this happened.

Charuwaka commented 3 years ago

sure thanks!