0

I want to install opencv library on IBM Cloud Functions to be able import cv2 into a Python action.

I tried to follow this guide:

https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_python_local_virtenv

I've done the following steps:

virtualenv virtualenv

source virtualenv/bin/activate

pip install opencv-python

deactivate

However, in this step 6:

import pyjokes

 def joke(params):
     return {"joke": pyjokes.get_joke()}

I didn't know how to make it suitable for opencv. Any advice is appreciated.

Thanks,

Jim
  • 1
  • 5
  • Your question is not clear. Do you need help adapting the CV2 functions similar to the joke example? Which functions do you want to use? If it is more complex, consider using a Docker image – data_henrik Jun 30 '20 at 12:27
  • Hello.. Yes.. I want to help adapting the CV2 functions similar to the joke example to be able to do "import cv2" in Python Actions in IBM Cloud Functions – Jim Jun 30 '20 at 14:41
  • I don't know CV2, but you would need to wrap the funcs you want to use in that submodule. Again, I recommend following the Docker way. It is straightforward – data_henrik Jun 30 '20 at 18:32
  • Thanks a lot for your reply,.I've followed your recommendation about using the docker image to deploy cv2 as an action in my cloud account.I'm now having cv2 as action there and when I invoke it gives: "{ "cv2": "4.2.0" }" ... The problem now is that when I import cv2 in a new action it gives this error: { "error": "Traceback (most recent call last):\n File \"/action/1/src/exec__.py\", line 43, in \n from main__ import main as main\n File \"/action/1/src/main__.py\", line 11, in \n import cv2\nModuleNotFoundError: No module named 'cv2'\n" } ... Any advice, plz? – Jim Jul 05 '20 at 13:08
  • Thanks .. I tried again,,I've put my code into __main__.py and and it's now working fine.. – Jim Jul 05 '20 at 16:47

0 Answers0