示例#1
0
 def _stream_frame_from_camera(self):
     numpy_array_jpeg_bytes = self.camera_manager.grab_frame()
     jpeg_string = int_numpy_array_to_str(numpy_array_jpeg_bytes)
     resized_jpeg_string = ImageResizer.from_raw_string(
         jpeg_string
     ).resize_to_width(PREVIEW_RESIZE_WIDTH)
     self.image_publisher.publish_frame(resized_jpeg_string)
示例#2
0
def send_photo_to_self(filename, recipient):
    full_path = os.path.join(UPLOAD_FOLDER, filename)
    with open(full_path, "rb") as f:
        jpeg_string = f.read()

    resized_jpeg_string = ImageResizer.from_raw_string(
        jpeg_string
    ).resize_to_width(FINISHED_RESIZE_WIDTH)

    b64_jpeg_string = base64.urlsafe_b64encode(resized_jpeg_string)
    post_url = "%s/picture/" % APP_SETTINGS["HTTP_LISTEN_URL"]
    post_data = {
        "b64jpeg": b64_jpeg_string,
        "phone_num_or_email": recipient
    }
    requests.post(post_url, data=post_data)
    os.remove(full_path)
示例#3
0
def send_photo(filename, phone_num_or_email):
    """ Assume the input image is for sell width """
    print "Starting to send photo to end user"
    full_path = "%s%s" % (APP_SETTINGS["UPLOAD_FOLDER"], filename)
    with open(full_path, "rb") as f:
        jpeg_string = f.read()

    jpeg_string = ImageRotater.from_raw_string(jpeg_string).rotate(
        COMPANY_SETTINGS["picture_rotation"])

    watermark_jpeg_string = ImageResizer.from_raw_string(
        jpeg_string).resize_to_width(
            COMPANY_SETTINGS["image_picture_view_width"])

    if COMPANY_SETTINGS["watermark_url"]:
        watermark_jpeg_string = default_watermark(watermark_jpeg_string)

    watermark_photo_uuid_str = str(uuid.uuid4())
    if COMPANY_SETTINGS["sell_photos"]:
        sell_photo_uuid_str = company_salted_uuid(watermark_photo_uuid_str)
        upload_image(jpeg_string, phone_num_or_email, sell_photo_uuid_str)

    watermark_image_url = upload_image(watermark_jpeg_string,
                                       phone_num_or_email,
                                       watermark_photo_uuid_str)
    # TODO if sell photos is online then we should instead do a new f*****g URL
    print watermark_image_url

    print phone_num_or_email

    try:
        facebook_image_url = _possibly_post_to_facebook(watermark_image_url)
    except Exception as e:  # Facebook token has expired
        print "FACEBOOK ACCESS TOKEN HAS LIKELY EXPIRED"
        print e
        facebook_image_url = None

    if COMPANY_SETTINGS["sell_photos"]:
        watermark_image_url = _sell_photo_url(watermark_image_url)

    image_url_for_user = facebook_image_url or watermark_image_url
    _send_image_back_to_user(phone_num_or_email, image_url_for_user)

    os.remove(full_path)
示例#4
0
def send_photo(filename, phone_num_or_email):
    """ Assume the input image is for sell width """
    print "Starting to send photo to end user"
    full_path = "%s%s" % (APP_SETTINGS["UPLOAD_FOLDER"], filename)
    with open(full_path, "rb") as f:
        jpeg_string = f.read()

    jpeg_string = ImageRotater.from_raw_string(
        jpeg_string
    ).rotate(COMPANY_SETTINGS["picture_rotation"])

    watermark_jpeg_string = ImageResizer.from_raw_string(
        jpeg_string
    ).resize_to_width(COMPANY_SETTINGS["image_picture_view_width"])

    if COMPANY_SETTINGS["watermark_url"]:
        watermark_jpeg_string = default_watermark(watermark_jpeg_string)

    watermark_photo_uuid_str = str(uuid.uuid4())
    if COMPANY_SETTINGS["sell_photos"]:
        sell_photo_uuid_str = company_salted_uuid(watermark_photo_uuid_str)
        upload_image(jpeg_string, phone_num_or_email, sell_photo_uuid_str)

    watermark_image_url = upload_image(watermark_jpeg_string, phone_num_or_email, watermark_photo_uuid_str)
    # TODO if sell photos is online then we should instead do a new f*****g URL
    print watermark_image_url

    print phone_num_or_email

    try:
        facebook_image_url = _possibly_post_to_facebook(watermark_image_url)
    except Exception as e:  # Facebook token has expired
        print "FACEBOOK ACCESS TOKEN HAS LIKELY EXPIRED"
        print e
        facebook_image_url = None

    if COMPANY_SETTINGS["sell_photos"]:
        watermark_image_url = _sell_photo_url(watermark_image_url)

    image_url_for_user = facebook_image_url or watermark_image_url
    _send_image_back_to_user(phone_num_or_email, image_url_for_user)

    os.remove(full_path)
示例#5
0
 def _stream_frame_from_camera(self):
     numpy_array_jpeg_bytes = self.camera_manager.grab_frame()
     jpeg_string = int_numpy_array_to_str(numpy_array_jpeg_bytes)
     resized_jpeg_string = ImageResizer.from_raw_string(
         jpeg_string).resize_to_width(PREVIEW_RESIZE_WIDTH)
     self.image_publisher.publish_frame(resized_jpeg_string)