3

我希望能够在不使用服务 url 的情况下将 blob(图像)加载到 Python 图像处理库或 numpy 数组中进行分析(例如均值、中值、标准差)。

这是我的图像数据库,t_image_url 包含 blob 的服务 url

from google.appengine.ext import db, blobstore    
class ImageModel(db.Model):
    t_image = blobstore.BlobReferenceProperty(required=True)
    t_imageUrl = db.StringProperty(required = True)

这是我尝试过的一部分

import numpy as np
import Image
import ImageOps
class ImageAnalysisHandler(BaseHandler):
    def get(self, imageModel_id):
        if self.user:           
            i = ImageModel.get_by_id(int(imageModel_id))
            OpenedImage = Image.open(i.t_image)
            self.render('imageAnalysis.html', imageD = i)
        else:
            self.redirect('login')

这显然不起作用,因为图像模块(来自 Python 图像库)不知道如何读取 blob。我想知道是否有人知道如何准确地将 blob 读入 PIL 或 numpy 数组。

4

1 回答 1

2

看看BlobReader 类。它使您可以使用类似文件的界面读取 blobstore 中的文件存储。

于 2013-05-06T23:20:53.020 回答