This commit is contained in:
Pavle Portic 2018-03-04 14:13:09 +01:00
parent 52a83beb3b
commit 13357c772d
351 changed files with 224 additions and 0 deletions

54
3/hough.py Normal file
View File

@ -0,0 +1,54 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 pavle <pavle.portic@tilda.center>
#
# Distributed under terms of the MIT license.
"""
@file hough_lines.py
@brief This program demonstrates line finding with the Hough transform
"""
import sys
import math
import cv2 as cv
import numpy as np
def main(argv):
default_file = "set/A6.png"
filename = argv[0] if len(argv) > 0 else default_file
# Loads an image
src = cv.imread(filename, cv.IMREAD_GRAYSCALE)
# Check if image is loaded fine
if src is None:
print ('Error opening image!')
print ('Usage: hough_lines.py [image_name -- default ' + default_file + '] \n')
return -1
dst = cv.Canny(src, 50, 200, None, 3)
# Copy edges to the images that will display the results in BGR
cdst = cv.cvtColor(dst, cv.COLOR_GRAY2BGR)
lines = cv.HoughLines(dst, 1, np.pi / 180, 150, None, 0, 0)
if lines is not None:
# for i in range(0, len(lines)):
for i in [ 0 ]:
rho = lines[i][0][0]
theta = lines[i][0][1]
a = math.cos(theta)
b = math.sin(theta)
x0 = a * rho
y0 = b * rho
pt1 = (int(x0 + 1000*(-b)), int(y0 + 1000*(a)))
pt2 = (int(x0 - 1000*(-b)), int(y0 - 1000*(a)))
cv.line(cdst, pt1, pt2, (0,0,255), 3, cv.LINE_AA)
print type(lines)
cv.imshow("Source", src)
cv.imshow("Detected Lines (in red) - Standard Hough Line Transform", cdst)
cv.waitKey()
return 0
if __name__ == "__main__":
main(sys.argv[1:])

1
3/inputs/A1.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A1.png

1
3/inputs/A10.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A10.png

1
3/inputs/A2.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A2.png

1
3/inputs/A3.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A3.png

1
3/inputs/A4.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A4.png

1
3/inputs/A5.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A5.png

1
3/inputs/A6.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A6.png

1
3/inputs/A7.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A7.png

1
3/inputs/A8.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A8.png

1
3/inputs/A9.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\A9.png

BIN
3/out_img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
3/out_res.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

1
3/outputs/1.out Normal file
View File

@ -0,0 +1 @@
475G

1
3/outputs/10.out Normal file
View File

@ -0,0 +1 @@
622G

1
3/outputs/2.out Normal file
View File

@ -0,0 +1 @@
684G

1
3/outputs/3.out Normal file
View File

@ -0,0 +1 @@
683G

1
3/outputs/4.out Normal file
View File

@ -0,0 +1 @@
56GG

1
3/outputs/5.out Normal file
View File

@ -0,0 +1 @@
151G

1
3/outputs/6.out Normal file
View File

@ -0,0 +1 @@
473G

1
3/outputs/7.out Normal file
View File

@ -0,0 +1 @@
564G

1
3/outputs/8.out Normal file
View File

@ -0,0 +1 @@
184G

1
3/outputs/9.out Normal file
View File

@ -0,0 +1 @@
153G

28
3/proba.py Normal file
View File

@ -0,0 +1,28 @@
import cv2 as cv
import numpy as np
images = ['set/A1.png','set/A2.png','set/A3.png','set/A4.png','set/A5.png','set/A6.png','set/A7.png','set/A8.png','set/A9.png','set/A10.png']
def main():
i = images[4]
img = cv.imread(i, 0)
kernel = np.ones((5,5),np.uint8)
closing = cv.morphologyEx(img, cv.MORPH_CLOSE, kernel)
cv.imshow("Closing", closing)
cv.imshow("Source", img)
cv.waitKey()
def rotateImage(image, angle):
image_center = tuple(np.array(image.shape)/2)
rot_mat = cv.getRotationMatrix2D(image_center,angle,1.0)
result = cv.warpAffine(image, rot_mat, image.shape,flags=cv.INTER_LINEAR)
return result
if __name__ == "__main__":
main()

BIN
3/publicDataSet.zip Normal file

Binary file not shown.

BIN
3/set/A1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

BIN
3/set/A10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
3/set/A2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

BIN
3/set/A3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

BIN
3/set/A4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

BIN
3/set/A5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
3/set/A6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
3/set/A7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

BIN
3/set/A8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

BIN
3/set/A9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
3/temp1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

BIN
3/temp2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
3/temp3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
3/temp4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
3/temp5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

35
4/hough_circle.py Normal file
View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 pavle <pavle.portic@tilda.center>
#
# Distributed under terms of the MIT license.
# set/example_
import cv2 as cv
import numpy as np
import os
def main():
root = raw_input()
filename = [f for f in os.listdir(root) if os.path.isfile(os.path.join(root, f))]
filename.sort()
filename = filename[0]
detect_circle(os.path.join(root, filename))
def detect_circle(filename):
src = cv.imread(filename, cv.IMREAD_COLOR)
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
rows = gray.shape[0]
circles = cv.HoughCircles(gray, cv.HOUGH_GRADIENT, 1, rows/16, 100, 100, 30, 1, 50)
if circles is not None:
circles = np.uint16(np.around(circles))
print circles[0][0][0], circles[0][0][1], 0, 0, 0, 0, 0
if __name__ == "__main__":
main()

67
4/hough_line.py Normal file
View File

@ -0,0 +1,67 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 pavle <pavle.portic@tilda.center>
#
# Distributed under terms of the MIT license.
"""
@file hough_lines.py
@brief This program demonstrates line finding with the Hough transform
"""
import sys
import math
import cv2 as cv
import numpy as np
def main(argv):
default_file = "set/example_2/frame_0001.png"
filename = argv[0] if len(argv) > 0 else default_file
# Loads an image
src = cv.imread(filename, cv.IMREAD_GRAYSCALE)
# Check if image is loaded fine
if src is None:
print ('Error opening image!')
print ('Usage: hough_lines.py [image_name -- default ' + default_file + '] \n')
return -1
dst = cv.Canny(src, 50, 200, None, 3)
# Copy edges to the images that will display the results in BGR
# cdst = cv.cvtColor(dst, cv.COLOR_GRAY2BGR)
cdstP = cv.cvtColor(dst, cv.COLOR_GRAY2BGR)
# cdstP = np.copy(cdst)
# lines = cv.HoughLines(dst, 1, np.pi / 180, 150, None, 0, 0)
# if lines is not None:
# for i in range(0, len(lines)):
# rho = lines[i][0][0]
# theta = lines[i][0][1]
# a = math.cos(theta)
# b = math.sin(theta)
# x0 = a * rho
# y0 = b * rho
# pt1 = (int(x0 + 1000*(-b)), int(y0 + 1000*(a)))
# pt2 = (int(x0 - 1000*(-b)), int(y0 - 1000*(a)))
# cv.line(cdst, pt1, pt2, (0,0,255), 3, cv.LINE_AA)
linesP = cv.HoughLinesP(dst, 1, np.pi / 180, 40, None, 40, 50)
print len(linesP)
if linesP is not None:
for i in range(0, len(linesP)):
l = linesP[i][0]
cv.line(cdstP, (l[0], l[1]), (l[2], l[3]), (0,0,255), 3, cv.LINE_AA)
cv.imshow("Source", src)
# cv.imshow("Detected Lines (in red) - Standard Hough Line Transform", cdst)
cv.imshow("Detected Lines (in red) - Probabilistic Line Transform", cdstP)
cv.waitKey()
return 0
if __name__ == "__main__":
main(sys.argv[1:])

1
4/inputs/example_1.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_1

1
4/inputs/example_10.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_10

1
4/inputs/example_2.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_2

1
4/inputs/example_3.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_3

1
4/inputs/example_4.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_4

1
4/inputs/example_5.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_5

1
4/inputs/example_6.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_6

1
4/inputs/example_7.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_7

1
4/inputs/example_8.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_8

1
4/inputs/example_9.txt Normal file
View File

@ -0,0 +1 @@
@@DATASET_DIR@@\example_9

1
4/outputs/1.out Normal file
View File

@ -0,0 +1 @@
186 99 7 2 116 1 28

1
4/outputs/10.out Normal file
View File

@ -0,0 +1 @@
209 175 8 3 119 15 26

1
4/outputs/2.out Normal file
View File

@ -0,0 +1 @@
135 138 9 4 164 1 28

1
4/outputs/3.out Normal file
View File

@ -0,0 +1 @@
153 195 11 5 125 10 29

1
4/outputs/4.out Normal file
View File

@ -0,0 +1 @@
154 172 8 0 73 2 13

1
4/outputs/5.out Normal file
View File

@ -0,0 +1 @@
208 227 8 0 102 6 22

1
4/outputs/6.out Normal file
View File

@ -0,0 +1 @@
208 126 7 2 157 8 25

1
4/outputs/7.out Normal file
View File

@ -0,0 +1 @@
146 150 9 5 99 1 16

1
4/outputs/8.out Normal file
View File

@ -0,0 +1 @@
137 141 9 0 65 16 23

1
4/outputs/9.out Normal file
View File

@ -0,0 +1 @@
127 188 9 0 63 25 33

BIN
4/publicDataSet.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Some files were not shown because too many files have changed in this diff Show More