3 and 4
|
@ -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:])
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A1.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A10.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A2.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A3.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A4.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A5.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A6.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A7.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A8.png
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\A9.png
|
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 67 B |
|
@ -0,0 +1 @@
|
|||
475G
|
|
@ -0,0 +1 @@
|
|||
622G
|
|
@ -0,0 +1 @@
|
|||
684G
|
|
@ -0,0 +1 @@
|
|||
683G
|
|
@ -0,0 +1 @@
|
|||
56GG
|
|
@ -0,0 +1 @@
|
|||
151G
|
|
@ -0,0 +1 @@
|
|||
473G
|
|
@ -0,0 +1 @@
|
|||
564G
|
|
@ -0,0 +1 @@
|
|||
184G
|
|
@ -0,0 +1 @@
|
|||
153G
|
|
@ -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()
|
||||
|
After Width: | Height: | Size: 414 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 416 KiB |
After Width: | Height: | Size: 414 KiB |
After Width: | Height: | Size: 415 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 415 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 372 B |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 5.3 KiB |
|
@ -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()
|
||||
|
|
@ -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:])
|
||||
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_1
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_10
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_2
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_3
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_4
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_5
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_6
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_7
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_8
|
|
@ -0,0 +1 @@
|
|||
@@DATASET_DIR@@\example_9
|
|
@ -0,0 +1 @@
|
|||
186 99 7 2 116 1 28
|
|
@ -0,0 +1 @@
|
|||
209 175 8 3 119 15 26
|
|
@ -0,0 +1 @@
|
|||
135 138 9 4 164 1 28
|
|
@ -0,0 +1 @@
|
|||
153 195 11 5 125 10 29
|
|
@ -0,0 +1 @@
|
|||
154 172 8 0 73 2 13
|
|
@ -0,0 +1 @@
|
|||
208 227 8 0 102 6 22
|
|
@ -0,0 +1 @@
|
|||
208 126 7 2 157 8 25
|
|
@ -0,0 +1 @@
|
|||
146 150 9 5 99 1 16
|
|
@ -0,0 +1 @@
|
|||
137 141 9 0 65 16 23
|
|
@ -0,0 +1 @@
|
|||
127 188 9 0 63 25 33
|
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.9 KiB |