Пример #1
0
 def takein(self):
     self.turn_red()
     ''' capture image'''
     os.system('fswebcam -r 1024x786  --jpeg 500 qw.jpeg')
     
     '''sleep to recover image'''
     time.sleep(5)
     
     '''extract qrcode'''
     myCode = QR(filename="/home/pi/Desktop/project/ikart/qw.jpeg")
     if myCode.decode():
         print myCode.data
         print myCode.data_type
         print myCode.data_to_string()
         
          '''send product'''
          self.send_product()
          
          
          '''update xml '''
          self.update_xml()
          
          
          '''display details on lED'''
          self.displaydetails()
Пример #2
0
    def takein(self):

        self.update_xml('')
        return




        self.turn_red()

        '''try:
            find=os.remove("/home/pi/Desktop/project/ikart/qw.jpeg")
        except OSError:
            pass'''

        ''' capture image'''
        try :
            '''fswebcam -d /dev/video0  -S 2 -s brightness=60% -s Contrast=15%  -s Gamma=50%  -p YUYV -r 1280x720 --jpeg 80 -s Sharpness=40% -s Saturation=15%   --title "New Zealand - Wellington - Tawa"  $DIR/$filename'''
            os.system('fswebcam -r 100x100  --jpeg 1000 qw.jpeg')

        except IOError:
            time.sleep(1)
            os.system('fswebcam -r 300x300 --jpeg 500 kqrcode.jpeg')

        '''sleep to recover image'''
        time.sleep(4)

        '''extract qrcode'''
        try :
            myCode = QR(filename="/home/pi/Desktop/project/ikart/kqrcode.jpeg")
            if myCode.decode():
                print myCode.data
                print myCode.data_type
                print myCode.data_to_string()

                m=myCode.data_to_string()
                print (m)

                '''update xml '''
                self.update_xml(m)



                '''display details on lED'''
                self.displaydetails()
        except IOError as e:
            print(e,'sfhgdfhsdhdsh',myCode,str(myCode))
            return 0
        pass
Пример #3
0
def Authentication(self, l):

    count = 0
    myCode = QR(filename=u"/home/pi/Desktop/image.png")
    myCode.decode()
    n = myCode.data_to_string()
    print n
Пример #4
0
def readtextfromQR():
    try :
        from qrtools import QR
        from codecs import BOM_UTF8
    except ImportError :
        print('Module qrtools missing! No QR-code import possible!')
        raise 
    myCode = QR()
    myCode.decode_webcam()
    key = myCode.data_to_string().strip()
    return key[len(BOM_UTF8):] # fixes zbar!
Пример #5
0
    def Authentication(self,l):
        
        count =0
        myCode=QR(filename=u"/home/pi/Desktop/image.png")
        myCode.decode()
	n=myCode.data_to_string() 
        for a in l:
            for y in a:
		x=y.encode("utf-8")
                if x == n[3:]:
                    count+=1
        return count
Пример #6
0
    def check_image_qr(self, path):
        myCode = QR(filename=path)
        if myCode.decode():
            self.qr_link = myCode.data_to_string()
            self.copy_link.set_sensitive(True)
            alert = NotifyAlert(10)
            alert.props.title = _("Code found")
            alert.props.msg = _("Click on toolbar button for "
                "copy link to clipboard.")
            alert.connect("response", lambda x,
                y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)
        else:
            self.qr_link = None
            self.copy_link.set_sensitive(False)
            alert = NotifyAlert(10)
            alert.props.title = _("Code not found")
            alert.props.msg = _("Try again, please focus the Qr "
                "Code in the camera.")
            alert.connect("response", lambda x,
                y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)

        self.stop_play.set_sensitive(False)
Пример #7
0
    def check_image_qr(self, path):
        myCode = QR(filename=path)
        if myCode.decode():
            self.qr_link = myCode.data_to_string()
            self.copy_link.set_sensitive(True)
            alert = NotifyAlert(10)
            alert.props.title = _("Code found")
            alert.props.msg = _("Click on toolbar button for "
                                "copy link to clipboard.")
            alert.connect("response",
                          lambda x, y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)
        else:
            self.qr_link = None
            self.copy_link.set_sensitive(False)
            alert = NotifyAlert(10)
            alert.props.title = _("Code not found")
            alert.props.msg = _("Try again, please focus the Qr "
                                "Code in the camera.")
            alert.connect("response",
                          lambda x, y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)

        self.stop_play.set_sensitive(False)
    resolution_level = 9
    
    num_cases = int(sys.stdin.readline())
    
    for num_case in range(num_cases):
        text_squares = sys.stdin.readline().rstrip('\r\n').split()

        squares = [ parse_square(s) for s in text_squares ]

        s = squares[0]
        
        for i in range(1, len(squares)):            
            s = add_squares(s, squares[i])       
               
        qrname = u'case%d_sum.png' % (num_case + 1)
        create_png(qrname, s, resolution_level)
        
        myCode = QR(filename=qrname)
        if myCode.decode():
            #m = md5.new()
            #m.update(myCode.data_to_string())
            #print m.hexdigest()
            secret = myCode.data_to_string()
            # Strip non iso-8859-1 characters
            secret = secret.decode('utf-8')
            secret = secret.encode('iso-8859-1', 'ignore')
            print secret
            
            

import os, re
from PIL import Image
from qrtools import QR

def extractFrames(giffile, outputdir):
    with Image.open(giffile) as frame:
        nframes = 0
        while frame:
            frame.save( '%s/%s-%s.gif' % (outputdir, os.path.basename(giffile), nframes ) , 'GIF')
            nframes += 1
            try:
                frame.seek( nframes )
            except EOFError:
                break;
        return True    


# extract every fram
extractFrames('fast_response_code.gif', 'dec3_frames')

# read qr code in each extracted image
path="./dec3_frames/"

nugget=''
for filename in sorted(os.listdir(path), key=lambda x: int(re.findall(r'\d+', x)[0])):
    myCode = QR(filename=path+filename)
    if myCode.decode():
      nugget+=myCode.data_to_string()
      
print nugget
Пример #10
0
# bruteforce missing section until readable
count=0
for i in itertools.product('01', repeat=60):
    count+=1
    if count%1000 ==0:
        print count
    
    for x in range(1,12):
        for y in range (10,14):
            if( i[((y-10)%4)*11 + x] == '0' ):
                pixels_out[x,y]=(0,0,0)
    
        
    
    
    outimg=outimg.resize((300,300))
    outimg.save("dec17_out.png","png") 
    
    
    
    # read qr code 
    nugget=''
    
    myCode = QR(filename="dec17_out.png")
    if myCode.decode():
      nugget=myCode.data_to_string()
      print nugget
      break
    #else:
    #    print "could not decode"
    #break
Пример #11
0
from qrtools import QR
import sys
#import argparse

arg = sys.argv
code = QR(filename=arg[1])
if code.decode():
  print "QR decoded data is : ", code.data
  print code.data_type
  print code.data_to_string()
import unicodedata

if __name__ == '__main__':
    resolution_level = 9

    num_cases = int(sys.stdin.readline())

    for num_case in range(num_cases):
        text_squares = sys.stdin.readline().rstrip('\r\n').split()

        squares = [parse_square(s) for s in text_squares]

        s = squares[0]

        for i in range(1, len(squares)):
            s = add_squares(s, squares[i])

        qrname = u'case%d_sum.png' % (num_case + 1)
        create_png(qrname, s, resolution_level)

        myCode = QR(filename=qrname)
        if myCode.decode():
            #m = md5.new()
            #m.update(myCode.data_to_string())
            #print m.hexdigest()
            secret = myCode.data_to_string()
            # Strip non iso-8859-1 characters
            secret = secret.decode('utf-8')
            secret = secret.encode('iso-8859-1', 'ignore')
            print secret
Пример #13
0
def decodeWebcam(self):
        qr = QR()
        qr.decode_webcam()
        if qr.data_to_string() != 'NULL':
Пример #14
0
xshift = abs(m) * width
new_width = width + int(round(xshift))
part2 = part2.transform((new_width, height), Image.AFFINE,
        (1.1, m, -xshift if m > 0 else 0, 0, 1.605, 0), Image.BILINEAR)
part2 = part2.resize((800, 700), Image.ANTIALIAS)
contrast = ImageEnhance.Contrast(part2)
part2 = contrast.enhance(1.2)

part2 = part2.crop((245, 80, 393, 301))
tri1 = [(10,10), (20,20), (10,20)]
tri2 = [(0,0), (0,220), (100,220)]
transformblit(tri1, tri2, blank, part2)
part2 = part2.resize((240, 278), Image.ANTIALIAS)


blank2 = Image.new("RGBA", (278, 278), (0,0,0,0))

contrast = ImageEnhance.Contrast(part2)
part2 = contrast.enhance(1.6)

blank2.paste(part2, (12, 4), part2)
blank2.paste(part1, (0, 0), part1)
blank2.save("./sol.png", "PNG")
part1.save("./part1.png", "PNG")
part2.save("./part2.png", "PNG")


myCode = QR(filename=u"./sol.png")
if myCode.decode():
  print myCode.data_to_string()
Пример #15
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  qrgen1.py
#  
#  Copyright 2013 psutton <*****@*****.**>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  
from qrtools import QR
myCode = QR(filename=u"/home/psutton/Documents/Python/qrcodes/qrcode.png")
if myCode.decode():
  print myCode.data
  print myCode.data_type
  print myCode.data_to_string()
Пример #16
0
url = "https://ss.freess.org"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, 'lxml')
QR_imgs = soup.findAll("a", {"class": "image fit"})
for qrimg in QR_imgs:
    n, img = qrimg['href'].split(",")
    raw_img = base64.b64decode(img)
    tmp_f = random_string(5)
    fp = open(tmp_f, "wb")
    fp.write(raw_img)
    fp.close()
    myCode = QR(filename=tmp_f)
    if myCode.decode():
        if (myCode.data_type == "text"):
            protocol, ss = myCode.data_to_string().split("://")
            format_print(base64.b64decode(ss), protocol)
    os.remove(tmp_f)

url = "https://shadowsocksr.cat"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, 'lxml')
QR_img_urls = soup.findAll("a", {"class": "overlay lightbox"})
for qrimgurl in QR_img_urls:
    imgurl = url + "/" + qrimgurl['href']
    r = requests.get(imgurl, headers=headers)
    tmp_f = random_string(5)
    imageFile = open(tmp_f, 'wb')
    for chunk in r.iter_content(100000):
        imageFile.write(chunk)
    imageFile.close()
Пример #17
0
from qrtools import QR

c = QR(filename='./qr-codes-business-cards.jpg')

if c.decode():
    print("QR Data = {}".format(c.data_to_string()))