Skip to content

Commit

Permalink
adds finding GCPs from your known GCP_list.txt
Browse files Browse the repository at this point in the history
most simple way to find your QR code in images.
put your QR text from the image into the gcp_list.txt. also add the lat/long values. all with colons. end it with an asterisk "*".
the code will now check all QR codes for this list. and prints, when it finds it.
format should be discussed!
  • Loading branch information
hornig committed Jun 15, 2019
1 parent d71bd85 commit ac26476
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
3 changes: 3 additions & 0 deletions gcp_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
5;50.0;10.0*
23;51.1;11.1*
42;52.2;12.2*
60 changes: 42 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,64 @@
import gcposm.utils


def get_qr_codes(processing_files):
for file in processing_files:
def load_your_gcp_list(file):

gcp_list = []
if os.path.exists(file):
with open(file, 'r') as infile:
for line in infile:
gcp_list.append(line.split("*")[0].split(";"))


return gcp_list

# zxing doesn't like windows separator and other strange characters, so we just change it
file = Path(file)
file = file.absolute().as_uri()

reader = zxing.BarCodeReader()
barcode = reader.decode(file)
# does not handle exceptions yet, when the file is NOT an image
def get_qr_codes(file):
# zxing doesn't like windows separator and other strange characters, so we just change it
file = Path(file)
file = file.absolute().as_uri()

if barcode is not None:
print("decoding", file)
print(barcode.format)
print(barcode.type)
print(barcode.raw)
print(barcode.parsed)
print(barcode.points)
print()
reader = zxing.BarCodeReader()
barcode = reader.decode(file, True)
# filename, try_harder = True
# does not handle exceptions yet, when the file is NOT an image

return barcode.format, barcode.type, barcode.raw, barcode.parsed, barcode.points


def main(filename):

# preparation
gcp_list = load_your_gcp_list("gcp_list.txt")


# now working time
if os.path.isdir(args.file):
print("loading in all files in folder:", filename)
processing_files = gcposm.utils.get_all_files(filename)

elif os.path.isfile(args.file):
print("loading in this file:", filename)
processing_files = gcposm.utils.get_one_file(filename)

else:
print("neither file nor folder. ending programm.")
return

get_qr_codes(processing_files)
for file in processing_files:
format, type, raw, parsed, points = get_qr_codes(file)

if format is not None:
print("qr found in", file, parsed)

#do stuff now...
for item in gcp_list:
if parsed == item[0]:
print("\t found a known gcp (", item[1] ,"/", item[2] ,") from your list")


else:
print("qr not found in", file)


def getArgs():
Expand All @@ -53,7 +77,7 @@ def getArgs():

parser = argparse.ArgumentParser()

parser.add_argument('-f', '--from', action='store', default="/",
parser.add_argument('-f', '--from', action='store', default=os.sep,
dest='file',
help='load in the file or folder')

Expand Down

0 comments on commit ac26476

Please sign in to comment.