示例#1
0
from PIL import Image
import os
from pylab import *
from src.WeiboPoster import *
from src.ImageGetter import *

im = array(Image.open('radar_image\\115.bmp').convert('RGB'))
#imc = array(Image.open('radar_image\Shanghai_calbirate.bmp'))
print im.shape, im.dtype
weibo = WeiboPoster()
pil_im = Image.fromarray(uint8(im))
pil_im.save("test.jpg")
imgGet = ImageGetter()
weibo.post_weibo_with_image("test with a pic",imgGet.convert_to_binary_file_stream(pil_im,"jpg"))
r = im[:,:,0]
g = im[:,:,1]
b = im[:,:,2]
figure()
imshow(r)
show()
figure()
imshow(g)
show()
figure()
imshow(b)
show()

print r
print g
print b
(height,weight) = r.shape
示例#2
0
    img_get = ImageGetter()
    img_analyzer = ImageAnalyzer()

    while True:
        try:
            img_data = img_get.get_radar_img("http://www.nmc.cn/publish/radar/qingpu.html")

            img_analyzer.set_region((235, 185, 330, 274))
            cropped_img = img_analyzer.crop_image(img_data)

            img_analyzer.set_region((37, 32, 46, 37))
            cropped_img2 = img_analyzer.crop_image(cropped_img)

            result = img_analyzer.analysis_image(cropped_img2)
            print("Check result: " + result)

            if status != result:
                string = "#AutoWeatherPoster# "
                string = string + "The weather at Jiangqiao is " + result
                string = string + ", Right Now"
                weibo = WeiboPoster()
                # weibo.post_weibo(string)
                weibo.post_weibo_with_image(string, img_get.convert_to_binary_file_stream(img_data, "jpg"))
                status = result

            time.sleep(600)

        except Exception, e:
            print(Exception, ":", e)
            continue