Ask Your Question
0

OpenCV using Cloud Function(Cloud Function Python)

asked 2018-03-24 07:20:03 -0600

Santhosh1 gravatar image

updated 2018-03-29 00:19:25 -0600

hi

I know this topic should actually be asked to the backend service provider who would be providing this service. Which I actually have done. I would still like to get an opinion from the OpenCV community for this as many of you would be more experienced than me.

Which of these services would work for OpenCV on backend with python?

GOOGLE APP ENGINE or COMPUTE ENGINE

Please guide.

I have already spent 2 weeks of my time trying to implement OpenCV through Google Cloud Functions BETA using Cloud Function Python ended up getting an error like this

Traceback (most recent call last):
File "function.py", line 3, in <module> File "/app/cloudfn/pip-cache-3.5/lib/python3.5/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module File "site-packages/cv2/__init__.py", line 4, in <module> File "/app/cloudfn/pip-cache-3.5/lib/python3.5/site-packages/PyInstaller/loader/pyimod03_importers.py", line 714, in load_module ImportError: libSM.so.6: cannot open shared object file: No such file or directory

which actually requires a library called libsm6which needs to be installed according to this link

I did pip install opencv-python==3.4.0.12 is there a way. How I can actually overcome this issue of libsm6 quickly?

PS: cloud function is suppose to be serverless so it wouldn't have libsm6 which the OpenCV requires

edit retag flag offensive close merge delete

Comments

1

ah, terrible, i know. latest PIP bindings all rely on Xwindows (they're probably trying to get the gui back)

latest i could use on heroku is opencv-python==3.3.0.9

(lacks all the dnn goodness, though)

but it's a PIP problem (not really an opencv one !), let's nagg their maintainers !

https://github.com/skvark/opencv-pyth...

berak gravatar imageberak ( 2018-03-24 07:33:34 -0600 )edit
1

I'll try with OpenCV3.3.09

Santhosh1 gravatar imageSanthosh1 ( 2018-03-25 23:47:42 -0600 )edit

Yup! OpenCV 3.3.0.9 working on the Cloud Function using Cloud Function python ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

Santhosh1 gravatar imageSanthosh1 ( 2018-03-29 00:18:22 -0600 )edit

@Santosh1 , what if you write an answer, what worked for you in the end ?

berak gravatar imageberak ( 2018-03-29 01:06:39 -0600 )edit
1

@berak Something like poker with 5 aces

LBerger gravatar imageLBerger ( 2018-03-29 10:38:37 -0600 )edit

@LBerger, maybe i misread it, but to my experience, using prebuilt opencv (python) versions in environments like that is more like playing with 2 aces only. (it's not about a hidden one, more about restrictions, due to maintainers being late)

berak gravatar imageberak ( 2018-03-29 10:49:45 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-03-29 07:26:11 -0600

Santhosh1 gravatar image

updated 2018-03-29 07:29:24 -0600

Cloud-Function is suppose to be serverless execution environment, you can read the overview for more info. It is suppose to be able to only execute javaScript.

To run python code on cloud-function, we have an unofficial build called cloud-function-python

How this actually works

The python code needs to be bundled up into an executable with all the lib required for the code to run(using pyinstaller and docker) In short the python objects are converted to javascript objects.

In my case I had to process an image stored on the cloud using OpenCV, the actual code for my purpose was only 29KB

I was able to perform required operation and extract the data from the image.

Worked out just fine for me.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-03-24 07:20:03 -0600

Seen: 4,418 times

Last updated: Mar 29 '18