}, {
    "value": "67",
    "name": "<"
}, {
    "value": "68",
    "name": ">"
}, {
    "value": "69",
    "name": "?"
}, {
    "value": "70",
    "name": "!"
}]

# インスタンス生成
m_ocr = ocr()
# 初期化
ret = m_ocr.initialize()

if not ret:
    print("OCR Initialize error")
    sys.exit()


def main(base64_str):
    # -------------------- 入力画像の読込み -------------------
    img_str = base64.b64decode(base64_str)
    img_bin = np.fromstring(img_str, dtype=np.uint8)
    img = cv2.imdecode(img_bin, 1)

    height = img.shape[0]
def main():
    # --------------------- 引数チェック ---------------------
    # if len(sys.argv) < 2:
    #     print("No argument!")
    #     # sys.stdout.flush()
    #     return

    # argvs = sys.argv
    # ------------------ ファイル存在チェック -----------------
    # file_path = sys.stdin.read()
    # if not os.path.exists(file_path) or not os.path.isfile(file_path):
    #     print("Invalid argument error!")
    #     return

    # -------------------- 入力画像の読込み -------------------
    # img = np.array(ip.read_full_image(file_path), dtype=np.uint8)

    ret, img = cap.read()
    # print(type(img))
    # if img == None:
    #     return False

    img = np.array(img, dtype=np.uint8)
    # print(img.shape)
    height = img.shape[0]
    width = img.shape[1]
    dim = img.shape[2]
    # バッファ列に成形
    buff = img.reshape(1, width * height * dim)

    # -------------------------- OCR -------------------------
    # インスタンス生成
    m_ocr = ocr()
    # 初期化
    ret = m_ocr.initialize()

    # ret = False
    if not ret:
        print("OCR Initialize error")
        sys.exit()

    # 推定開始
    start = time.clock()
    try:
        res = m_ocr.predict_text(buff, width * height * dim, width, height)
        # print("OCR time: " + str(time.clock() - start) + "[sec]")

        if len(res) == 0:
            ip.show_video(img)
            return True

        for bbox in res:
            # print(bbox)
            # bboxを描画
            cv2.rectangle(
                img,
                (bbox["bbox"]["min_x"], bbox["bbox"]["min_y"]),
                (bbox["bbox"]["max_x"], bbox["bbox"]["max_y"]),
                (255, 0, 255),
                2  #stroke
            )
            # 数値描画の背景を描画
            cv2.rectangle(
                img,
                (bbox["bbox"]["min_x"] - 1, bbox["bbox"]["min_y"] - 15),
                (bbox["bbox"]["max_x"] + 1, bbox["bbox"]["min_y"]),
                (255, 0, 255),
                -1  # stroke=-1で塗りつぶし
            )
            # 数値テキスト
            font_size = int(
                (bbox["bbox"]["max_y"] - bbox["bbox"]["min_y"]) / 3)
            start_x = int(
                (bbox["bbox"]["min_x"] + bbox["bbox"]["max_x"]) / 2) - 5
            start_y = bbox["bbox"]["min_y"] - 1
            cv2.putText(img, str(CHAR_LIST[bbox["number"]]["name"]),
                        (start_x, start_y), cv2.FONT_HERSHEY_DUPLEX, 0.5,
                        (255, 255, 255))

        ip.show_video(img)

    except Exception as e:
        print(e.message)

    # # print(res)
    # test = {}
    # test["result"] = res
    # test["image"] = buff
    # print("==chunk start==")
    # sys.stdout.write(json.dumps(test))
    # print("==chunk end==")
    # sys.stdout.flush()

    return True
示例#3
0
engine.runAndWait()

print("Do you want to know whats arround you? or you want to read something? Press F for surroundings and j for Reading!!")

button=raw_input()



if(button=='j'):

	engine.say("You Have selected to reed, Switching on camera..., Press Escape to Capture")

	engine.runAndWait()
	Camera(filepath)

	OCRContent=ocr(filepath)

	engine.say("Do you want to Summarize the data you just snapped? Press F for Yes and J for no")
	engine.runAndWait()
	input1=raw_input()

	#time.sleep(20)
	if(input1=='f'):
		engine.say("You have selected For Summarizing")
		engine.runAndWait()
		SummarizerContent=summarizeMe(OCRContent)
		engine.say(SummarizerContent)
		engine.runAndWait()
		print(SummarizerContent.encode('utf-8'))

	elif(input1=='j'):
示例#4
0
 while True:
     start.tts("Choose a function")
     operation = start.stt("shortanswer")
     if operation in start.getcommand("maps"):
         maps.mapsloop()
     elif operation in start.getcommand("facerec"):
         start.writefunction("f")
         while (not (start.readfunction()=="a")):
                 time.sleep(0.1) //delay
         start.writefunction("r")
         start.modeluse = True
     elif operation in start.getcommand("ocr"):
         start.writefunction("f")
         time.sleep(1)
         img = cv2.imread("./frame.jpg")
         output = ocr(img)
         read_short = output.split("\n")
         start.tts(",".join(read_short[0:start.getconfig("minreadlines")]))
         if len(read_short) > 2:
                 start.tts("Continue")
                 operation = start.stt("veryshortanswer")
         else:
                 operation = "no"
         if operation == "yes":
             for i in range(start.getconfig("minreadlines"),len(read_short)):
                 start.tts(read_short[i])     
     elif operation in start.getcommand("caption"):
         start.writefunction("f")
         while (not (start.readfunction()=="a")):
                 time.sleep(0.1)
         start.writefunction("c")
示例#5
0
def apply(uid, pw, date=10):
    # 为相关参数进行url编码
    keyword = urllib.quote(KEYWORD_J.encode("Shift_JIS"))
    if date == 10:
        eventtarget = "dgd1%24_ctl2%24lkbKouen"
        selkibou1 = "2017061010001"
    else:
        eventtarget = "dgd1%24_ctl3%24lkbKouen"
        selkibou1 = "2017061110001"
    # 创建session
    session = requests.session()
    # 访问活动页
    resp = session.get('http://www.cnplayguide.com/evt/evtlst.aspx?kcd=79654')
    # 获得VIEWSTATE, VIEWSTATESENERATOR和scd
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 0, 1, 0)
    if error == 1:
        print "Failed in line 26."
        return 1
    # 访问6.10详情页
    data = '__EVENTTARGET=' + eventtarget + '&' \
           '__EVENTARGUMENT=&' \
           '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'Keyword=' + keyword + '&' \
           'scd=' + scd + '&' \
           'CnSimulation=&' \
           'dmf='
    headers = {
        'Accept':
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Encoding':
        'gzip, deflate',
        'Accept-Language':
        'zh-CN,zh;q=0.8',
        'Cache-Control':
        'max-age=0',
        'Connection':
        'keep-alive',
        'Content-Length':
        '1468',
        'Content-Type':
        'application/x-www-form-urlencoded',
        'DNT':
        '1',
        'Host':
        'www.cnplayguide.com',
        'Origin':
        'http://www.cnplayguide.com',
        'Referer':
        'http://www.cnplayguide.com/evt/evtlst.aspx?kcd=79654',
        'Upgrade-Insecure-Requests':
        '1',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
        'Chrome/57.0.2987.133 Safari/537.36'
    }
    resp = session.post('http://www.cnplayguide.com/evt/evtlst.aspx?kcd=79654',
                        data=data,
                        headers=headers)
    # print resp.history
    # 获取targeturl
    reg_targeturl = ur"MM_openBrWindow\('(.*?)',"
    try:
        targeturl = re.search(reg_targeturl, resp.text).group(1)
    except:
        print "Failed in line 60."
        return 1
    # 打开申请窗口
    headers = {
        'Accept':
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Encoding':
        'gzip, deflate, sdch, br',
        'Accept-Language':
        'zh-CN,zh;q=0.8',
        'Cache-Control':
        'max-age=0',
        'Connection':
        'keep-alive',
        'Content-Type':
        'application/x-www-form-urlencoded',
        'DNT':
        '1',
        'Host':
        'www.cnplayguide.com',
        'Referer':
        'http://www.cnplayguide.com/evt/evtdtl.aspx?ecd=CNI21395',
        'Upgrade-Insecure-Requests':
        '1',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
        'Chrome/57.0.2987.133 Safari/537.36'
    }
    resp = session.get(targeturl, headers=headers)
    # 获得VIEWSTATE, VIEWSTATESENERATOR, sid和imgaddr
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 1)
    if error == 1:
        print "Failed in line 81."
        return 1
    failure = 1
    while failure:
        # 画像认证
        imageauth = "Error"
        while imageauth == "Error":
            r = requests.get(imgaddr, stream=True)
            with open("img.gif", 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024):
                    f.write(chunk)
                    f.flush()
            imageauth = ocr()
        # 发送表单
        data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
               '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
               'selKibou1=' + selkibou1 + '&' \
               'rdbSekishu_1=2X&' \
               'selMaisu_1_2X_1=1&' \
               'hdnZaikoFlg_1_2X_1=0&' \
               'imageauth=' + imageauth + '&' \
               'LOGINUSER='******'&' \
               'LOGINPASS='******'&' \
               'next.x=27&' \
               'next.y=5&' \
               'sid=' + sid + '&' \
               'hidMaxMaisu=1&' \
               'shiteiFukusuFlg=1'
        headers['Accept-Encoding'] = 'gzip, deflate, br'
        headers['Content-Length'] = '4344'
        headers['Origin'] = 'https://www.cnplayguide.com'
        headers['Referer'] = targeturl
        resp = session.post(targeturl, data=data, headers=headers)
        # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
        (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
         error) = grab(resp.text, 1, 1, 1, 0, 0)
        if error == 1:
            print "Failed in line 117."
            return 1
        # 检查验证码
        reg5 = ur'入力した文字が画像と一致しません'
        if re.search(reg5, resp.text) is None:
            print "Verify code passed."
            failure = 0
        else:
            # 验证码错误
            print "Verify code failed."
            # 返回
            headers['Accept-Encoding'] = 'gzip, deflate, sdch, br'
            resp = session.get(targeturl,
                               headers=headers,
                               cookies=session.cookies)
            # 获得VIEWSTATE, VIEWSTATESENERATOR, sid和imgaddr
            (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
             error) = grab(resp.text, 1, 1, 1, 0, 1)
            if error == 1:
                print "Failed in line 133."
                return 1
    # 确认支付方式
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'ksigrdrdo=30%2C0%2C1%2C0%2C0&' \
           'cardtxt1=&' \
           'cardtxt2=&' \
           'cardtxt3=&' \
           'cardtxt4=&' \
           'cardsectxt1=&' \
           'cardsel1=01&' \
           'cardsel2=17&' \
           'cardnamesei=&' \
           'cardnamemei=&' \
           'mailcheck=mailcheck&' \
           'imgbtnnext.x=34&' \
           'imgbtnnext.y=3&' \
           'sid=' + sid + '&' \
           'futaiKbnMiasu=%2C1'
    headers['Content-Length'] = '8269'
    resp = session.post('https://www.cnplayguide.com/rsv/stslc_l.aspx',
                        data=data,
                        headers=headers)
    # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 0)
    if error == 1:
        print "Failed in line 158."
        return 1
    # 最终确认
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'moushikomi.x=45&' \
           'moushikomi.y=12&' \
           'sid=' + sid + '&' \
           'futaiflg='
    headers['Content-Length'] = '2097'
    headers['Referer'] = 'https://www.cnplayguide.com/rsv/stslc_l.aspx'
    resp = session.post('https://www.cnplayguide.com/rsv/apconf_l.aspx',
                        data=data,
                        headers=headers)
    # 注册成功
    reg5 = ur'お申込が完了いたしました。'
    if re.search(reg5, resp.text) is None:
        return 1
    else:
        return 0
示例#6
0
def btnOCR():
    term = ocr()
    jres = {'detail': term}

    return jsonify(jres)
示例#7
0
def ImageOCR():
    return ocr(request.files.get('file').file)
示例#8
0
def create(mailaddr):
    # 为相关参数进行url编码
    mailaddr = urllib.quote(mailaddr)
    keyword = urllib.quote(KEYWORD_J.encode("Shift_JIS"))
    msg = urllib.quote(MSG_J.encode("Shift_JIS"))
    msg_utf8 = MSG_J.encode('unicode_escape').replace('\\', "%")
    sei_kanji = urllib.quote(SEI_KANJI_J.encode("Shift_JIS"))
    mei_kanji = urllib.quote(MEI_KANJI_J.encode("Shift_JIS"))
    sei_kana = urllib.quote(SEI_KANA_J.encode("Shift_JIS"))
    mei_kana = urllib.quote(MEI_KANA_J.encode("Shift_JIS"))
    # 创建session
    session = requests.session()
    # 1. 访问首页
    resp = session.get('http://www.cnplayguide.com')
    # 2. 访问会员申请页面
    resp = session.get('http://www.cnplayguide.com/mem/cpmemcgi.aspx')
    # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 0)
    if error == 1:
        return 1
    # 3. 提交会员申请
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'Keyword=' + keyword + '&' \
           'txtFindKeitaiMail=&' \
           'CN%83v%83%8C%89%EF%88%F5%82%C9%90%5C%82%B5%8D%9E%82%DE.x=55&' \
           'CN%83v%83%8C%89%EF%88%F5%82%C9%90%5C%82%B5%8D%9E%82%DE.y=5&' \
           'sid=' + sid
    headers = {
        'Accept':
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Encoding':
        'gzip, deflate',
        'Accept-Language':
        'zh-CN,zh;q=0.8',
        'Cache-Control':
        'max-age=0',
        'Connection':
        'keep-alive',
        'Content-Length':
        '680',
        'Content-Type':
        'application/x-www-form-urlencoded',
        'DNT':
        '1',
        'Host':
        'www.cnplayguide.com',
        'Origin':
        'http://www.cnplayguide.com',
        'Referer':
        'http://www.cnplayguide.com/mem/cpmemcgi.aspx',
        'Upgrade-Insecure-Requests':
        '1',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
        'Chrome/57.0.2987.133 Safari/537.36'
    }
    resp = session.post('http://www.cnplayguide.com/mem/cpmemcgi.aspx',
                        data=data,
                        headers=headers,
                        cookies=session.cookies)
    # print resp.history
    # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 0)
    if error == 1:
        return 1
    # 4. 同意条款
    headers[
        'Referer'] = 'http://www.cnplayguide.com/mem/cpmemag.aspx?kkb=03&msg='
    headers['Content-Length'] = '483'
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'Keyword=' + keyword + '&' \
           '%93%AF%88%D3%82%B7%82%E9.x=35&' \
           '%93%AF%88%D3%82%B7%82%E9.y=11&' \
           'sid=' + sid + '&' \
           'kkb=03'
    resp = session.post(
        'http://www.cnplayguide.com/mem/cpmemag.aspx?kkb=03&msg=',
        data=data,
        headers=headers,
        cookies=session.cookies)
    # print resp.history
    # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 0)
    if error == 1:
        return 1
    # 5. 提交表单
    headers[
        'Referer'] = 'https://www.cnplayguide.com/mem/memr_b.aspx?kkb=03&msg='
    headers['Content-Length'] = '2017'
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'Keyword=' + keyword + '&' \
           'txtNAME_SEI_KANJI=' + sei_kanji + '&' \
           'txtNAME_MEI_KANJI=' + mei_kanji + '&' \
           'txtNAME_SEI_KANA=' + sei_kana + '&' \
           'txtNAME_MEI_KANA=' + mei_kana + '&' \
           'txtNICK_NAME=TuTou&' \
           'txtNen=1990&' \
           'drpTuki=01&' \
           'drpHi=01&' \
           'rdosex=1&' \
           'drpSyokuGyo=1&' \
           'txtTEL_JITAKU_1=&' \
           'txtTEL_JITAKU_2=&' \
           'txtTEL_JITAKU_3=&' \
           'txtTEL_KEITAI_1=080&' \
           'txtTEL_KEITAI_2=6600&' \
           'txtTEL_KEITAI_3=0817&' \
           'rdoAddress=1&' \
           'txtPC_ADDRESS=' + mailaddr + '&' \
           'txtKEITAI_ADDRESS=&' \
           'txtPOST_JITAKU1=192&' \
           'txtPOST_JITAKU2=0916&' \
           'drpJitakuKen=13&' \
           'txtJITAKU_SIKUGUN=%94%AA%89%A4%8Eq&' \
           'txtJITAKU_THOUMEI=%82%DD%82%C8%82%DD%96%EC&' \
           'txtJITAKU_BUIL=5-12-7%81%40101&' \
           'rdoDM=2&' \
           '%8E%9F%82%D6.x=35&' \
           '%8E%9F%82%D6.y=11&' \
           'sid=' + sid + '&' \
           'kkb=03'
    resp = session.post(
        'https://www.cnplayguide.com/mem/memr_b.aspx?kkb=03&msg=',
        data=data,
        headers=headers,
        cookies=session.cookies)
    # # print resp.history
    # 获得VIEWSTATE, VIEWSTATESENERATOR, sid和imgaddr
    (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
     error) = grab(resp.text, 1, 1, 1, 0, 1)
    if error == 1:
        return 1
    failure = 1
    while failure:
        # 画像认证
        imageauth = "Error"
        while imageauth == "Error":
            r = requests.get(imgaddr, stream=True)
            with open("img.gif", 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024):
                    f.write(chunk)
                    f.flush()
            # Image.open('img.gif').show()
            # imageauth = raw_input("直接输入验证码数字:")
            imageauth = ocr()
        # 6. 提交
        headers[
            'Referer'] = 'https://www.cnplayguide.com/mem/memr_m.aspx?sid=%s&kkb=03&msg=&cnt=58' % sid
        headers['Content-Length'] = '2017'
        data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
               '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
               'Keyword=' + keyword + '&' \
               'rdoArea=00&' \
               'rdoMarumaga=2&' \
               'rdoMyPage=0&' \
               'imageauth=' + imageauth + '&' \
               '%8E%9F%82%D6.x=27&' \
               '%8E%9F%82%D6.y=4&' \
               'hdnKeyword=&' \
               'sid=' + sid + '&' \
               'kkb=03&' \
               'count=58&' \
               'Hidden2=&' \
               'Hidden1=0&' \
               'hdnKeyWordFlg=&' \
               'hdnNextFlg=1&' \
               'hdnGazouHenkoFlg='
        resp = session.post(
            'https://www.cnplayguide.com/mem/memr_m.aspx?sid=%s&kkb=03&msg=&cnt=58'
            % sid,
            data=data,
            headers=headers,
            cookies=session.cookies)
        # print resp.history
        # 获得VIEWSTATE, VIEWSTATESENERATOR和sid
        (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
         error) = grab(resp.text, 1, 1, 1, 0, 0)
        if error == 1:
            return 1
        # 检查验证码
        reg = ur'入力した文字が画像と一致しません'
        if re.search(reg, resp.text) is None:
            print "Verify code passed."
            failure = 0
        else:
            # 验证码错误
            print "Verify code failed."
            # 返回
            headers['Referer'] = 'https://www.cnplayguide.com/mem/memr_m.aspx?sid=%s&kkb=03&msg=%s&cnt=58&kcnt=0' \
                                 % (sid, msg)
            headers['Content-Length'] = '926'
            data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
                   '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
                   'Keyword=' + keyword + '&' \
                   'Imagebutton1.x=38&' \
                   'Imagebutton1.y=12&' \
                   'hdnKeyword=&' \
                   'sid=' + sid + '&' \
                   'kkb=03&' \
                   'count=58&' \
                   'Hidden2=&' \
                   'Hidden1=0&' \
                   'hdnKeyWordFlg=&' \
                   'hdnNextFlg=&' \
                   'hdnGazouHenkoFlg='
            resp = session.post(
                'https://www.cnplayguide.com/mem/memr_m.aspx?sid=%s&kkb=03&msg=%s&cnt=58&kcnt=0'
                % (sid, msg_utf8),
                data=data,
                headers=headers,
                cookies=session.cookies)
            # 获得VIEWSTATE, VIEWSTATESENERATOR, sid和imgaddr
            (VIEWSTATE_url, VIEWSTATEGENERATOR, sid, scd, imgaddr,
             error) = grab(resp.text, 1, 1, 1, 0, 1)
            if error == 1:
                return 1
    # 7. 确认内容
    headers[
        'Referer'] = 'https://www.cnplayguide.com/mem/memrconf.aspx?sid=%s&kkb=03&msg=&cnt=58&kcnt=0&mps=0' % sid
    headers['Content-Length'] = '1322'
    data = '__VIEWSTATE=' + VIEWSTATE_url + '&' \
           '__VIEWSTATEGENERATOR=' + VIEWSTATEGENERATOR + '&' \
           'Keyword=' + keyword + '&' \
           '%93o%98%5E.x=32&' \
           '%93o%98%5E.y=9&' \
           'sid=' + sid + '&' \
           'kkb=03'
    resp = session.post(
        'https://www.cnplayguide.com/mem/memrconf.aspx?sid=%s&kkb=03&msg=&cnt=58&kcnt=0&mps=0'
        % sid,
        data=data,
        headers=headers,
        cookies=session.cookies)
    # # print resp.history
    # 注册成功
    reg = ur'CNプレ会員への登録が完了しました。'
    if re.search(reg, resp.text) is None:
        reg = ur'ご入力された会員情報は既に登録されています。'
        if re.search(reg, resp.text) is None:
            return 1
        else:
            with open('mailaddressfinished.txt', 'a') as maddrf:
                maddrf.write("%s has been Used.\n" % mailaddr)
    else:
        return 0
示例#9
0
def main(file_path):
    # --------------------- 引数チェック ---------------------
    if len(sys.argv) < 2:
        print("No argument!")
        return

    # ------------------ ファイル存在チェック -----------------
    if not os.path.exists(file_path) or not os.path.isfile(file_path):
        print("Invalid argument error!")
        return

    # -------------------- 入力画像の読込み -------------------
    img = np.array(ip.read_full_image(file_path), dtype=np.uint8)
    height = img.shape[0]
    width = img.shape[1]
    dim = img.shape[2]
    # バッファ列に成形
    buff = img.reshape(1, width * height * dim)

    # -------------------------- OCR -------------------------
    # インスタンス生成
    m_ocr = ocr()
    # 初期化
    ret = m_ocr.initialize()

    # ret = False
    if not ret:
        print("OCR Initialize error")
        sys.exit()

    # 推定開始
    start = time.clock()
    try:
        res = m_ocr.predict_text(buff, width * height * dim, width, height)
        print("OCR time: " + str(time.clock() - start) + "[sec]")

    except Exception as e:
        print(e.message)

    if debug:
        for d in res:
            ans = d["number"]
            b = d["bbox"]
            label_miny = b["min_y"] - 30
            label_maxy = b["min_y"]
            if label_miny < 0:
                label_miny = b["max_y"]
                label_maxy = b["max_y"] + 30

            font_x = b["max_x"] - int((b["max_x"] - b["min_x"]) / 2) - 9
            font_y = label_maxy - int((label_maxy - label_miny) / 2) + 9

            cv2.rectangle(img, (b["min_x"], b["min_y"]),
                          (b["max_x"], b["max_y"]), (0, 0, 255), 2)
            cv2.rectangle(img, (b["min_x"] - 1, label_miny),
                          (b["max_x"] + 1, label_maxy), (0, 0, 255), -1)
            print((font_x, font_y))
            cv2.putText(img, TEXT_LIST[d["number"]]["char"], (font_x, font_y),
                        cv2.FONT_HERSHEY_COMPLEX_SMALL, 1.5, (255, 255, 255),
                        2)

        cv2.imshow("result", img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
    else:
        result = {}
        result["result"] = res
        print("==chunk start==")
        sys.stdout.write(json.dumps(result))
        print("==chunk end==")
        sys.stdout.flush()