python - 在Python Bluemix服务器中写入图像

标签 python opencv flask ibm-cloud

我正在尝试在Python Blumix服务器中使用opencv处理后保存图像,但是发生错误。我正在读取推送应用程序时上传的本地镜像,但是无法在同一位置书写。

image = cv2.imread('static/images/image.jpg') #works

# do some process to the image...

cv2.imwrite('static/images/processed.jpg', processed_image) #works in local but not in server

我需要一些权限吗?特殊文件夹?服务器是只读的?

提前致谢

最佳答案

我可能希望将对象存储用于图像。如果您以后想要将代码拆分为微服务,这将为您提供更多选择。不建议使用本地存储:

Avoid Writing to the Local File System

Applications running on Cloud Foundry should not write files to the local file system for the following reasons:

  • Local file system storage is short-lived. When an application instance crashes or stops, the resources assigned to that instance are reclaimed by the platform including any local disk changes made since the app started. When the instance is restarted, the application will start with a new disk image. Although your application can write local files while it is running, the files will disappear after the application restarts.

  • Instances of the same application do not share a local file system. Each application instance runs in its own isolated container. Thus a file written by one instance is not visible to other instances of the same application. If the files are temporary, this should not be a problem. However, if your application needs the data in the files to persist across application restarts, or the data needs to be shared across all running instances of the application, the local file system should not be used. We recommend using a shared data service like a database or blobstore for this purpose.

Source: https://docs.cloudfoundry.org/devguide/deploy-apps/prepare-to-deploy.html#filesystem

关于python - 在Python Bluemix服务器中写入图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43265308/

相关文章:

python - 如何检查文件夹是否存在然后将其删除?

python - 如何禁用flask app.run() 的默认消息?

c - 与 Supervisord 一起使用非连续程序

python - 测试 Flask 登录和身份验证?

Python Ctypes 将 void 指针转换为 nonetype 和 long。有什么影响?这是什么意思?

python - Django SMTP [Errno 111] 连接被拒绝

python - 使用 PyDot 排列点图的头部?

c++ - 创建蒙版以选择黑色区域

opencv - CvTrack 和 CvBlob 有什么区别?

c++ - 使用 OpenCV 检测指尖而不是面部