Skip to content

Commit ac26476

Browse files
committed
adds finding GCPs from your known GCP_list.txt
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!
1 parent d71bd85 commit ac26476

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

gcp_list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
5;50.0;10.0*
2+
23;51.1;11.1*
3+
42;52.2;12.2*

main.py

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,64 @@
66
import gcposm.utils
77

88

9-
def get_qr_codes(processing_files):
10-
for file in processing_files:
9+
def load_your_gcp_list(file):
10+
11+
gcp_list = []
12+
if os.path.exists(file):
13+
with open(file, 'r') as infile:
14+
for line in infile:
15+
gcp_list.append(line.split("*")[0].split(";"))
16+
17+
18+
return gcp_list
1119

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

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

20-
if barcode is not None:
21-
print("decoding", file)
22-
print(barcode.format)
23-
print(barcode.type)
24-
print(barcode.raw)
25-
print(barcode.parsed)
26-
print(barcode.points)
27-
print()
26+
reader = zxing.BarCodeReader()
27+
barcode = reader.decode(file, True)
28+
# filename, try_harder = True
29+
# does not handle exceptions yet, when the file is NOT an image
30+
31+
return barcode.format, barcode.type, barcode.raw, barcode.parsed, barcode.points
2832

2933

3034
def main(filename):
35+
36+
# preparation
37+
gcp_list = load_your_gcp_list("gcp_list.txt")
38+
39+
40+
# now working time
3141
if os.path.isdir(args.file):
3242
print("loading in all files in folder:", filename)
3343
processing_files = gcposm.utils.get_all_files(filename)
3444

3545
elif os.path.isfile(args.file):
3646
print("loading in this file:", filename)
3747
processing_files = gcposm.utils.get_one_file(filename)
48+
3849
else:
3950
print("neither file nor folder. ending programm.")
4051
return
4152

42-
get_qr_codes(processing_files)
53+
for file in processing_files:
54+
format, type, raw, parsed, points = get_qr_codes(file)
55+
56+
if format is not None:
57+
print("qr found in", file, parsed)
58+
59+
#do stuff now...
60+
for item in gcp_list:
61+
if parsed == item[0]:
62+
print("\t found a known gcp (", item[1] ,"/", item[2] ,") from your list")
63+
64+
65+
else:
66+
print("qr not found in", file)
4367

4468

4569
def getArgs():
@@ -53,7 +77,7 @@ def getArgs():
5377

5478
parser = argparse.ArgumentParser()
5579

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

0 commit comments

Comments
 (0)