This commit is contained in:
louiscklaw
2025-01-31 23:00:36 +08:00
parent 94b9851d7a
commit 460fc0f81d
24255 changed files with 319077 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
%YAML:1.0
---
data: !!opencv-matrix
rows: 3
cols: 3
dt: i
data: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

View File

@@ -0,0 +1,190 @@
import cv2 as cv
import numpy as np
from glob import glob
# the directory of the image database
database_dir = "image.orig"
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def retrieval():
# beach correct
# building mountain
# bus mountain
# dinosaur correct
# flower beach
# horse correct
# man beach
print("1: beach")
print("2: building")
print("3: bus")
print("4: dinosaur")
print("5: flower")
print("6: horse")
print("7: man")
choice = input("Type in the number to choose a category and type enter to confirm\n")
if choice == "1":
src_input = cv.imread("beach.jpg")
print("You choose: %s - beach\n" % choice)
if choice == "2":
src_input = cv.imread("building.jpg")
print("You choose: %s - building\n" % choice)
if choice == "3":
src_input = cv.imread("bus.jpg")
print("You choose: %s - bus\n" % choice)
if choice == "4":
src_input = cv.imread("dinosaur.jpg")
print("You choose: %s - dinosaur\n" % choice)
if choice == "5":
src_input = cv.imread("flower.jpg")
print("You choose: %s - flower\n" % choice)
if choice == "6":
src_input = cv.imread("horse.jpg")
print("You choose: %s - horse\n" % choice)
if choice == "7":
src_input = cv.imread("man.jpg")
print("You choose: %s - man\n" % choice)
min_diff = 1e50
# src_input = cv.imread("man.jpg")
cv.imshow("Input", src_input)
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
# read image database
database = sorted(glob(database_dir + "/*.jpg"))
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
# compare the two images by histogram, uncomment the following line to use histogram
# diff = compareImgs_hist(src_gray, img_gray)
print(img, diff)
# find the minimum difference
if diff <= min_diff:
# update the minimum difference
min_diff = diff
# update the most similar image
closest_img = img_rgb
result = img
print("the most similar image is %s, the pixel-by-pixel difference is %f " % (result, min_diff))
print("\n")
cv.imshow("Result", closest_img)
cv.waitKey(0)
cv.destroyAllWindows()
def SIFT():
img1 = cv.imread("flower.jpg")
img2 = cv.imread("image.orig/684.jpg")
if img1 is None or img2 is None:
print("Error loading images!")
exit(0)
# -- Step 1: Detect the keypoints using SIFT Detector, compute the descriptors
minHessian = 400
detector = cv.SIFT_create()
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)
# -- Step 2: Matching descriptor vectors with a brute force matcher
matcher = cv.DescriptorMatcher_create(cv.DescriptorMatcher_BRUTEFORCE)
matches = matcher.match(descriptors1, descriptors2)
# -- Draw matches
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches)
# -- Show detected matches
cv.imshow("Matches: SIFT (Python)", img_matches)
cv.waitKey()
# draw good matches
matches = sorted(matches, key=lambda x: x.distance)
min_dist = matches[0].distance
good_matches = tuple(filter(lambda x: x.distance <= 2 * min_dist, matches))
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(
img1,
keypoints1,
img2,
keypoints2,
good_matches,
img_matches,
flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS,
)
# -- Show detected matches
cv.imshow("Good Matches: SIFT (Python)", img_matches)
cv.waitKey()
def main():
# img = cv.imread("beach.jpg")
# cv.imshow("Image", img)
# from matplotlib import pyplot as plt
# plt.hist(img.ravel(),10,[0,256]); plt.show()
# gray_img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# cv.imshow("Gray Image", gray_img)
# cv.waitKey()
print("1: Image retrieval demo")
print("2: SIFT demo")
number = int(input("Type in the number to choose a demo and type enter to confirm\n"))
if number == 1:
retrieval()
elif number == 2:
SIFT()
# pass
else:
print("Invalid input")
exit()
main()

View File

@@ -0,0 +1,59 @@
import cv2 as cv
import numpy as np
from glob import glob
# the directory of the image database
database_dir = "image.orig"
def is_same_image_sift(img1_path, img2_path):
# Load images
img1 = cv.imread(img1_path)
img2 = cv.imread(img2_path)
if img1 is None or img2 is None:
print("Error loading images!")
return False
# Detect keypoints and compute descriptors
minHessian = 400
detector = cv.SIFT_create()
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)
# Match descriptors
matcher = cv.DescriptorMatcher_create(cv.DescriptorMatcher_BRUTEFORCE)
matches = matcher.match(descriptors1, descriptors2)
# Filter out low-quality matches
matches = sorted(matches, key=lambda x: x.distance)
min_dist = matches[0].distance
good_matches = tuple(filter(lambda x: x.distance <= 2 * min_dist, matches))
# Calculate similarity or distance
if len(good_matches) > 0:
# You can calculate the similarity or distance based on the number of good matches
similarity = len(good_matches) / len(matches)
print(f"Similarity: {similarity}")
return similarity > 0.5
else:
print("No good matches found.")
return False
def main():
# img = cv.imread("beach.jpg")
# cv.imshow("Image", img)
# from matplotlib import pyplot as plt
# plt.hist(img.ravel(),10,[0,256]); plt.show()
# gray_img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# cv.imshow("Gray Image", gray_img)
# cv.waitKey()
# Example usage
img1_path = "test_img/flower.jpg"
img2_path = "image.orig/684.jpg"
if is_same_image_sift(img1_path, img2_path):
print("Images are likely the same.")
else:
print("Images are likely different.")
main()

View File

@@ -0,0 +1,188 @@
import cv2 as cv
import numpy as np
from glob import glob
# the directory of the image database
database_dir = "image.orig"
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def retrieval(choice):
output = []
# print("1: beach")
# print("2: building")
# print("3: bus")
# print("4: dinosaur")
# print("5: flower")
# print("6: horse")
# print("7: man")
# choice = input(
# "Type in the number to choose a category and type enter to confirm\n"
# )
src_input = ""
if choice == "1":
src_input = cv.imread("beach.jpg")
print("You choose: %s - beach\n" % choice)
elif choice == "2":
src_input = cv.imread("building.jpg")
print("You choose: %s - building\n" % choice)
elif choice == "3":
src_input = cv.imread("bus.jpg")
print("You choose: %s - bus\n" % choice)
elif choice == "4":
src_input = cv.imread("dinosaur.jpg")
print("You choose: %s - dinosaur\n" % choice)
elif choice == "5":
src_input = cv.imread("flower.jpg")
print("You choose: %s - flower\n" % choice)
elif choice == "6":
src_input = cv.imread("horse.jpg")
print("You choose: %s - horse\n" % choice)
elif choice == "7":
src_input = cv.imread("man.jpg")
print("You choose: %s - man\n" % choice)
else:
print("Invalid input")
exit()
min_diff = 1e50
# src_input = cv.imread("man.jpg")
# cv.imshow("Input", src_input)
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
# read image database
database = sorted(glob(database_dir + "/*.jpg"))
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
output.append(
[int(img.replace(database_dir + "/", "").replace(".jpg", "")), img, diff]
)
# compare the two images by histogram, uncomment the following line to use histogram
# diff = compareImgs_hist(src_gray, img_gray)
# print(img, diff)
# find the minimum difference
if diff <= min_diff:
# update the minimum difference
min_diff = diff
# update the most similar image
closest_img = img_rgb
result = img
# print(
# "the most similar image is %s, the pixel-by-pixel difference is %f "
# % (result, min_diff)
# )
# closest_img
# cv.destroyAllWindows()
return output
def SIFT():
img1 = cv.imread("flower.jpg")
img2 = cv.imread("image.orig/685.jpg")
if img1 is None or img2 is None:
print("Error loading images!")
exit(0)
# -- Step 1: Detect the keypoints using SIFT Detector, compute the descriptors
minHessian = 400
detector = cv.SIFT_create()
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)
# -- Step 2: Matching descriptor vectors with a brute force matcher
matcher = cv.DescriptorMatcher_create(cv.DescriptorMatcher_BRUTEFORCE)
matches = matcher.match(descriptors1, descriptors2)
# -- Draw matches
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches)
# -- Show detected matches
cv.imshow("Matches: SIFT (Python)", img_matches)
cv.waitKey()
# draw good matches
matches = sorted(matches, key=lambda x: x.distance)
min_dist = matches[0].distance
good_matches = tuple(filter(lambda x: x.distance <= 2 * min_dist, matches))
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(
img1,
keypoints1,
img2,
keypoints2,
good_matches,
img_matches,
flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS,
)
# -- Show detected matches
cv.imshow("Good Matches: SIFT (Python)", img_matches)
cv.waitKey()
def test_performance(number):
# print("1: Image retrieval demo")
# print("2: SIFT demo")
if number == 1:
retrieval_results = retrieval("1")
from pprint import pprint
pprint(retrieval_results)
elif number == 2:
SIFT()
# pass
else:
print("Invalid input")
exit()
test_performance(1)

View File

@@ -0,0 +1,155 @@
import cv2 as cv
import numpy as np
from glob import glob
from pprint import pprint
# the directory of the image database
database_dir = "image.orig"
def countCorrectImage(in_array):
output = 0
for item in in_array:
if item[0] >= 100 and item[0] < 200:
output += 1
return output
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def histLowerBoundAndUpperBound(retrieval_results, lower_bound, uper_bound):
filtered_results = [
item for item in retrieval_results if lower_bound <= item[2] <= uper_bound
]
return filtered_results
def retrieval(src_input, database):
output = []
min_diff = 1e50
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
output.append(
[
int(img.replace(database_dir + "/", "").replace(".jpg", "")),
img,
diff,
]
)
return output
def retrievalTest():
output = []
src_input = cv.imread("beach.jpg")
# precision
retrieval_precision_results = retrieval(
src_input, sorted(glob(database_dir + "/*.jpg"))
)
# recall
retrieval_recall_test_result = retrieval(
src_input, sorted(glob(database_dir + "/1**.jpg"))
)
# sliced_array = retrieval_results[100:200]
# third_element = [item[2] for item in sliced_array]
# lower_limit = min(third_element)
# upper_limit = max(third_element)
# (np.uint64(30241636), np.uint64(62158322))
# filtered_results = [
# item
# for item in retrieval_results
# if np.uint64(30241636) <= item[2] <= np.uint64(62158322)
# ]
# number of retrieved images
# whatever the image classified using my strategy
lu_bound_test_result = histLowerBoundAndUpperBound(
retrieval_precision_results, np.uint64(30241636), np.uint64(62158322)
)
# number of retrived images that are from the correct category
precision_correct_count = countCorrectImage(lu_bound_test_result)
# Precision
number_of_retrived_image = len(lu_bound_test_result)
precision_pct = str((precision_correct_count / number_of_retrived_image) * 100)
print("correct from retrived image: ".ljust(50) + str(precision_correct_count))
print("number of retrived image: ".ljust(50) + str(number_of_retrived_image))
print("precision/correct rate (%, target 60%): ".ljust(50) + precision_pct)
# number of retrived images that are from the correct category
# total number of images in the target category of the dataset
# pprint("recall:" + str(recall_correct_count / 100))
return [precision_correct_count, number_of_retrived_image, precision_pct]
def test_performance(number):
# print("1: Image retrieval demo")
# print("2: SIFT demo")
if number == 1:
metrics = retrievalTest()
pprint(metrics)
# sliced_array = retrieval_results[101:200]
# third_element = [item[2] for item in sliced_array]
# max_diff = max(third_element)
# min_diff = min(third_element)
# pprint([max_diff, min_diff])
else:
print("Invalid input")
exit()
test_performance(1)

View File

@@ -0,0 +1,7 @@
import os
for filename in os.listdir():
if filename.endswith(".jpg"):
num = int(os.path.splitext(filename)[0])
new_filename = "{:03d}.jpg".format(num)
os.rename(filename, new_filename)

View File

@@ -0,0 +1,4 @@
https://gist.github.com/demid5111/6faa590e4fc5813550dd95cc1c538893
### Hough transform
https://www.youtube.com/watch?app=desktop&v=XRBc_xkZREg

View File

@@ -0,0 +1,16 @@
import json
# Create some data
data ={
"mat" :[[1,2,3],[4,5,6],[7,8,9]],
"threshold": 0.5
}
# Write to JSON
with open( 'data.json', 'w') as f:
json.dump(data, f)
# Read from JSON
with open( 'data.json', 'r') as f:
data_read = json. load(f)
print (data_read)

View File

@@ -0,0 +1,15 @@
import cv2
import numpy as np
# Create some data
data = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Write to XML
fs = cv2.FileStorage("data.yaml", cv2.FILE_STORAGE_WRITE)
fs.write("data", data)
fs.release()
# Read from XML
fs = cv2.FileStorage("data.yaml", cv2.FILE_STORAGE_READ)
data_read = fs.getNode("data").mat()
print(data_read)

View File

@@ -0,0 +1 @@
python demo_draft1.py

Binary file not shown.

View File

@@ -0,0 +1,190 @@
import cv2 as cv
import numpy as np
from glob import glob
# the directory of the image database
database_dir = "image.orig"
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def retrieval():
# beach correct
# building mountain
# bus mountain
# dinosaur correct
# flower beach
# horse correct
# man beach
print("1: beach")
print("2: building")
print("3: bus")
print("4: dinosaur")
print("5: flower")
print("6: horse")
print("7: man")
choice = input("Type in the number to choose a category and type enter to confirm\n")
if choice == "1":
src_input = cv.imread("beach.jpg")
print("You choose: %s - beach\n" % choice)
if choice == "2":
src_input = cv.imread("building.jpg")
print("You choose: %s - building\n" % choice)
if choice == "3":
src_input = cv.imread("bus.jpg")
print("You choose: %s - bus\n" % choice)
if choice == "4":
src_input = cv.imread("dinosaur.jpg")
print("You choose: %s - dinosaur\n" % choice)
if choice == "5":
src_input = cv.imread("flower.jpg")
print("You choose: %s - flower\n" % choice)
if choice == "6":
src_input = cv.imread("horse.jpg")
print("You choose: %s - horse\n" % choice)
if choice == "7":
src_input = cv.imread("man.jpg")
print("You choose: %s - man\n" % choice)
min_diff = 1e50
# src_input = cv.imread("man.jpg")
cv.imshow("Input", src_input)
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
# read image database
database = sorted(glob(database_dir + "/*.jpg"))
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
# compare the two images by histogram, uncomment the following line to use histogram
# diff = compareImgs_hist(src_gray, img_gray)
print(img, diff)
# find the minimum difference
if diff <= min_diff:
# update the minimum difference
min_diff = diff
# update the most similar image
closest_img = img_rgb
result = img
print("the most similar image is %s, the pixel-by-pixel difference is %f " % (result, min_diff))
print("\n")
cv.imshow("Result", closest_img)
cv.waitKey(0)
cv.destroyAllWindows()
def SIFT():
img1 = cv.imread("flower.jpg")
img2 = cv.imread("image.orig/684.jpg")
if img1 is None or img2 is None:
print("Error loading images!")
exit(0)
# -- Step 1: Detect the keypoints using SIFT Detector, compute the descriptors
minHessian = 400
detector = cv.SIFT_create()
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)
# -- Step 2: Matching descriptor vectors with a brute force matcher
matcher = cv.DescriptorMatcher_create(cv.DescriptorMatcher_BRUTEFORCE)
matches = matcher.match(descriptors1, descriptors2)
# -- Draw matches
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches)
# -- Show detected matches
cv.imshow("Matches: SIFT (Python)", img_matches)
cv.waitKey()
# draw good matches
matches = sorted(matches, key=lambda x: x.distance)
min_dist = matches[0].distance
good_matches = tuple(filter(lambda x: x.distance <= 2 * min_dist, matches))
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(
img1,
keypoints1,
img2,
keypoints2,
good_matches,
img_matches,
flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS,
)
# -- Show detected matches
cv.imshow("Good Matches: SIFT (Python)", img_matches)
cv.waitKey()
def main():
# img = cv.imread("beach.jpg")
# cv.imshow("Image", img)
# from matplotlib import pyplot as plt
# plt.hist(img.ravel(),10,[0,256]); plt.show()
# gray_img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# cv.imshow("Gray Image", gray_img)
# cv.waitKey()
print("1: Image retrieval demo")
print("2: SIFT demo")
number = int(input("Type in the number to choose a demo and type enter to confirm\n"))
if number == 1:
retrieval()
elif number == 2:
SIFT()
# pass
else:
print("Invalid input")
exit()
main()

View File

@@ -0,0 +1,188 @@
import cv2 as cv
import numpy as np
from glob import glob
# the directory of the image database
database_dir = "image.orig"
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def retrieval(choice):
output = []
# print("1: beach")
# print("2: building")
# print("3: bus")
# print("4: dinosaur")
# print("5: flower")
# print("6: horse")
# print("7: man")
# choice = input(
# "Type in the number to choose a category and type enter to confirm\n"
# )
src_input = ""
if choice == "1":
src_input = cv.imread("beach.jpg")
print("You choose: %s - beach\n" % choice)
elif choice == "2":
src_input = cv.imread("building.jpg")
print("You choose: %s - building\n" % choice)
elif choice == "3":
src_input = cv.imread("bus.jpg")
print("You choose: %s - bus\n" % choice)
elif choice == "4":
src_input = cv.imread("dinosaur.jpg")
print("You choose: %s - dinosaur\n" % choice)
elif choice == "5":
src_input = cv.imread("flower.jpg")
print("You choose: %s - flower\n" % choice)
elif choice == "6":
src_input = cv.imread("horse.jpg")
print("You choose: %s - horse\n" % choice)
elif choice == "7":
src_input = cv.imread("man.jpg")
print("You choose: %s - man\n" % choice)
else:
print("Invalid input")
exit()
min_diff = 1e50
# src_input = cv.imread("man.jpg")
# cv.imshow("Input", src_input)
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
# read image database
database = sorted(glob(database_dir + "/*.jpg"))
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
output.append(
[int(img.replace(database_dir + "/", "").replace(".jpg", "")), img, diff]
)
# compare the two images by histogram, uncomment the following line to use histogram
# diff = compareImgs_hist(src_gray, img_gray)
# print(img, diff)
# find the minimum difference
if diff <= min_diff:
# update the minimum difference
min_diff = diff
# update the most similar image
closest_img = img_rgb
result = img
# print(
# "the most similar image is %s, the pixel-by-pixel difference is %f "
# % (result, min_diff)
# )
# closest_img
# cv.destroyAllWindows()
return output
def SIFT():
img1 = cv.imread("flower.jpg")
img2 = cv.imread("image.orig/685.jpg")
if img1 is None or img2 is None:
print("Error loading images!")
exit(0)
# -- Step 1: Detect the keypoints using SIFT Detector, compute the descriptors
minHessian = 400
detector = cv.SIFT_create()
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)
# -- Step 2: Matching descriptor vectors with a brute force matcher
matcher = cv.DescriptorMatcher_create(cv.DescriptorMatcher_BRUTEFORCE)
matches = matcher.match(descriptors1, descriptors2)
# -- Draw matches
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches)
# -- Show detected matches
cv.imshow("Matches: SIFT (Python)", img_matches)
cv.waitKey()
# draw good matches
matches = sorted(matches, key=lambda x: x.distance)
min_dist = matches[0].distance
good_matches = tuple(filter(lambda x: x.distance <= 2 * min_dist, matches))
img_matches = np.empty(
(max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], 3),
dtype=np.uint8,
)
cv.drawMatches(
img1,
keypoints1,
img2,
keypoints2,
good_matches,
img_matches,
flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS,
)
# -- Show detected matches
cv.imshow("Good Matches: SIFT (Python)", img_matches)
cv.waitKey()
def test_performance(number):
# print("1: Image retrieval demo")
# print("2: SIFT demo")
if number == 1:
retrieval_results = retrieval("1")
from pprint import pprint
pprint(retrieval_results)
elif number == 2:
SIFT()
# pass
else:
print("Invalid input")
exit()
test_performance(1)

View File

@@ -0,0 +1,155 @@
import cv2 as cv
import numpy as np
from glob import glob
from pprint import pprint
# the directory of the image database
database_dir = "image.orig"
def countCorrectImage(in_array):
output = 0
for item in in_array:
if item[0] >= 100 and item[0] < 200:
output += 1
return output
# Compute pixel-by-pixel difference and return the sum
def compareImgs(img1, img2):
# resize img2 to img1
img2 = cv.resize(img2, (img1.shape[1], img1.shape[0]))
diff = cv.absdiff(img1, img2)
return diff.sum()
def compareImgs_hist(img1, img2):
width, height = img1.shape[1], img1.shape[0]
img2 = cv.resize(img2, (width, height))
num_bins = 10
hist1 = [0] * num_bins
hist2 = [0] * num_bins
bin_width = 255.0 / num_bins + 1e-4
# compute histogram from scratch
# for w in range(width):
# for h in range(height):
# hist1[int(img1[h, w] / bin_width)] += 1
# hist2[int(img2[h, w] / bin_width)] += 1
# compute histogram by using opencv function
# https://docs.opencv.org/4.x/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
hist1 = cv.calcHist([img1], [0], None, [num_bins], [0, 255])
hist2 = cv.calcHist([img2], [0], None, [num_bins], [0, 255])
sum = 0
for i in range(num_bins):
sum += abs(hist1[i] - hist2[i])
return sum / float(width * height)
def histLowerBoundAndUpperBound(retrieval_results, lower_bound, uper_bound):
filtered_results = [
item for item in retrieval_results if lower_bound <= item[2] <= uper_bound
]
return filtered_results
def retrieval(src_input, database):
output = []
min_diff = 1e50
# change the image to gray scale
src_gray = cv.cvtColor(src_input, cv.COLOR_BGR2GRAY)
for img in database:
# read image
img_rgb = cv.imread(img)
# convert to gray scale
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
# compare the two images
diff = compareImgs(src_gray, img_gray)
output.append(
[
int(img.replace(database_dir + "/", "").replace(".jpg", "")),
img,
diff,
]
)
return output
def retrievalTest():
output = []
src_input = cv.imread("beach.jpg")
# precision
retrieval_precision_results = retrieval(
src_input, sorted(glob(database_dir + "/*.jpg"))
)
# recall
retrieval_recall_test_result = retrieval(
src_input, sorted(glob(database_dir + "/1**.jpg"))
)
# sliced_array = retrieval_results[100:200]
# third_element = [item[2] for item in sliced_array]
# lower_limit = min(third_element)
# upper_limit = max(third_element)
# (np.uint64(30241636), np.uint64(62158322))
# filtered_results = [
# item
# for item in retrieval_results
# if np.uint64(30241636) <= item[2] <= np.uint64(62158322)
# ]
# number of retrieved images
# whatever the image classified using my strategy
lu_bound_test_result = histLowerBoundAndUpperBound(
retrieval_precision_results, np.uint64(30241636), np.uint64(62158322)
)
# number of retrived images that are from the correct category
precision_correct_count = countCorrectImage(lu_bound_test_result)
# Precision
number_of_retrived_image = len(lu_bound_test_result)
precision_pct = str((precision_correct_count / number_of_retrived_image) * 100)
print("correct from retrived image: ".ljust(50) + str(precision_correct_count))
print("number of retrived image: ".ljust(50) + str(number_of_retrived_image))
print("precision/correct rate (%, target 60%): ".ljust(50) + precision_pct)
# number of retrived images that are from the correct category
# total number of images in the target category of the dataset
# pprint("recall:" + str(recall_correct_count / 100))
return [precision_correct_count, number_of_retrived_image, precision_pct]
def test_performance(number):
# print("1: Image retrieval demo")
# print("2: SIFT demo")
if number == 1:
metrics = retrievalTest()
pprint(metrics)
# sliced_array = retrieval_results[101:200]
# third_element = [item[2] for item in sliced_array]
# max_diff = max(third_element)
# min_diff = min(third_element)
# pprint([max_diff, min_diff])
else:
print("Invalid input")
exit()
test_performance(1)

View File

@@ -0,0 +1,7 @@
import os
for filename in os.listdir():
if filename.endswith(".jpg"):
num = int(os.path.splitext(filename)[0])
new_filename = "{:03d}.jpg".format(num)
os.rename(filename, new_filename)

View File

@@ -0,0 +1,4 @@
https://gist.github.com/demid5111/6faa590e4fc5813550dd95cc1c538893
### Hough transform
https://www.youtube.com/watch?app=desktop&v=XRBc_xkZREg

View File

@@ -0,0 +1 @@
python demo_draft1.py

View File

@@ -0,0 +1,54 @@
import cv2
import os,sys
path, filename = os.path.split(os.path.realpath(__file__))
nfiles = os.popen('find ./iut_n |grep -i jpg').read().splitlines()
print(nfiles)
false_positive = 0
# for i in range(9,9+1):
for nf in nfiles:
print(nf)
# 读取待检测的图像
image = cv2.imread(nf)
# 获取 XML 文件,加载人脸检测器
faceCascade = cv2.CascadeClassifier("cascade.xml")
# 色彩转换,转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 调用函数 detectMultiScale
faces = faceCascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=1, minSize=(5, 5))
# print(faces)
# 打印输出的测试结果
# print("发现{0}个人脸!".format(len(faces)))
if len(faces) == 1:
false_positive += 1
# 逐个标注人脸
for x, y, w, h in faces:
cv2.imwrite("matches_n/d_{0}.jpg".format(len(os.listdir("matches_n"))), image[y:y+h,x:x+w])
# cv2.rectangle(image, (x, y), (x + w, y + w), (0, 255, 0), 2) # 矩形标注
# cv2.circle(image,(int((x+x+w)/2),int((y+y+h)/2)),int(w/2),(0,255,0),2)
for x, y, w, h in faces:
# cv2.imwrite("matches/{0}.jpg".format(len(os.listdir("matches"))), image[y:y+h,x:x+w])
cv2.rectangle(image, (x, y), (x + w, y + w), (0, 255, 0), 2) # 矩形标注
# cv2.circle(image,(int((x+x+w)/2),int((y+y+h)/2)),int(w/2),(0,255,0),2)
# 显示结果
# cv2.imshow("dect", image)
# 保存检测结果
# cv2.imwrite("re.jpg", image)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
print(false_positive)

View File

@@ -0,0 +1,52 @@
import cv2
import os,sys
path, filename = os.path.split(os.path.realpath(__file__))
nfiles = os.popen('find ./iut_p |grep -i jpg').read().splitlines()
print(nfiles)
correct_num = 0
# for i in range(9,9+1):
for nf in nfiles:
# print(nf)
# 读取待检测的图像
image = cv2.imread(nf)
# 获取 XML 文件,加载人脸检测器
faceCascade = cv2.CascadeClassifier("cascade.xml")
# 色彩转换,转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 调用函数 detectMultiScale
faces = faceCascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=1, minSize=(5, 5))
if len(faces) == 1:
correct_num += 1
# print(faces)
# 打印输出的测试结果
# print("发现{0}个人脸!".format(len(faces)))
# 逐个标注人脸
for x, y, w, h in faces:
cv2.imwrite("matches_p/d_{0}.jpg".format(len(os.listdir("matches_p"))), image[y:y+h,x:x+w])
# cv2.rectangle(image, (x, y), (x + w, y + w), (0, 255, 0), 2) # 矩形标注
# cv2.circle(image,(int((x+x+w)/2),int((y+y+h)/2)),int(w/2),(0,255,0),2)
for x, y, w, h in faces:
# cv2.imwrite("matches/{0}.jpg".format(len(os.listdir("matches"))), image[y:y+h,x:x+w])
cv2.rectangle(image, (x, y), (x + w, y + w), (0, 255, 0), 2) # 矩形标注
# cv2.circle(image,(int((x+x+w)/2),int((y+y+h)/2)),int(w/2),(0,255,0),2)
# 显示结果
# cv2.imshow("dect", image)
# 保存检测结果
# cv2.imwrite("re.jpg", image)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
print(correct_num)

View File

@@ -0,0 +1,18 @@
import cv2
import os, random
def resize_images_in_folder(folder_path, size=(64, 64)):
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
if os.path.isfile(file_path):
img = cv2.imread(file_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
resized_img = cv2.resize(gray, size)
new_filename = '{:08x}.png'.format(random.getrandbits(32))
new_file_path = os.path.join(folder_path, new_filename)
cv2.imwrite(new_file_path, resized_img)
os.remove(file_path)
resize_images_in_folder('matches')

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -ex
rm -rf matches_{n,p}/*.jpg matches_{n,p}/*.png
python ./face_test_n.py
python ./face_test_p.py
wait

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -ex
opencv_visualisation --image=./data/test.png --model=./data/cascade.xml --data=./data/result/

View File

@@ -0,0 +1,31 @@
import cv2
import os,sys
# 读取待检测的图像
image = cv2.imread("cars.jpg")
# 获取 XML 文件,加载人脸检测器
faceCascade = cv2.CascadeClassifier("cascade.xml")
# 色彩转换,转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 调用函数 detectMultiScale
faces = faceCascade.detectMultiScale(gray, scaleFactor=1.15, minNeighbors=5, minSize=(5, 5))
# print(faces)
# 打印输出的测试结果
print("发现{0}个人脸!".format(len(faces)))
# 逐个标注人脸
for x, y, w, h in faces:
cv2.imwrite("matches/{0}.jpg".format(len(os.listdir("matches"))), image[y:y+h,x:x+w])
cv2.rectangle(image, (x, y), (x + w, y + w), (0, 255, 0), 2) # 矩形标注
# cv2.circle(image,(int((x+x+w)/2),int((y+y+h)/2)),int(w/2),(0,255,0),2)
# 显示结果
cv2.imshow("dect", image)
# 保存检测结果
cv2.imwrite("re.jpg", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

View File

@@ -0,0 +1,18 @@
import cv2
import os, random
def resize_images_in_folder(folder_path, size=(64, 64)):
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
if os.path.isfile(file_path):
img = cv2.imread(file_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
resized_img = cv2.resize(gray, size)
new_filename = '{:08x}.png'.format(random.getrandbits(32))
new_file_path = os.path.join(folder_path, new_filename)
cv2.imwrite(new_file_path, resized_img)
os.remove(file_path)
resize_images_in_folder('matches')

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -ex
rm -rf matches/*.jpg matches/*.png
python ./face_test.py

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -ex
opencv_visualisation --image=./data/test.png --model=./data/cascade.xml --data=./data/result/

View File

@@ -0,0 +1,27 @@
import os
import cv2
import numpy as np
def create_negative_description_file(path,file_name):
for image in os.listdir(path):
line = path+image
with open(file_name,'a') as f:
f.write(line)
f.write('\n')
def create_positive_description_file(path,file_name):
#image_names = os.listdir(path)
for image in os.listdir(path):
line = path+image+' 1 0 0 64 64'
with open(file_name,'a') as f:
f.write(line)
f.write('\n')
create_positive_description_file('D:/drive/pos/','info.txt')
create_negative_description_file('D:/drive/neg/','bg.txt')

View File

@@ -0,0 +1,244 @@
<?xml version="1.0"?>
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
<featureType>HAAR</featureType>
<height>24</height>
<width>24</width>
<stageParams>
<boostType>GAB</boostType>
<minHitRate>9.9500000476837158e-01</minHitRate>
<maxFalseAlarm>5.0000000000000000e-01</maxFalseAlarm>
<weightTrimRate>9.4999999999999996e-01</weightTrimRate>
<maxDepth>1</maxDepth>
<maxWeakCount>100</maxWeakCount></stageParams>
<featureParams>
<maxCatCount>0</maxCatCount>
<featSize>1</featSize>
<mode>BASIC</mode></featureParams>
<stageNum>5</stageNum>
<stages>
<!-- stage 0 -->
<_>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-1.4478853940963745e+00</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 14 -8.9639797806739807e-03</internalNodes>
<leafValues>
9.4078946113586426e-01 -8.7986546754837036e-01</leafValues></_>
<_>
<internalNodes>
0 -1 4 -1.8076587468385696e-02</internalNodes>
<leafValues>
-5.6646192073822021e-01 9.8937672376632690e-01</leafValues></_>
<_>
<internalNodes>
0 -1 13 -7.8208204358816147e-03</internalNodes>
<leafValues>
9.2043370008468628e-01 -6.0580855607986450e-01</leafValues></_>
<_>
<internalNodes>
0 -1 0 -3.4435594081878662e-01</internalNodes>
<leafValues>
-7.9926961660385132e-01 6.0425055027008057e-01</leafValues></_></weakClassifiers></_>
<!-- stage 1 -->
<_>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-7.9288864135742188e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 11 4.9917697906494141e-02</internalNodes>
<leafValues>
8.4966927766799927e-01 -9.3601649999618530e-01</leafValues></_>
<_>
<internalNodes>
0 -1 15 -1.1758920736610889e-03</internalNodes>
<leafValues>
7.4418127536773682e-01 -7.5894588232040405e-01</leafValues></_>
<_>
<internalNodes>
0 -1 4 -1.0608324781060219e-02</internalNodes>
<leafValues>
-6.0105341672897339e-01 9.8875778913497925e-01</leafValues></_></weakClassifiers></_>
<!-- stage 2 -->
<_>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-9.7797828912734985e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 6 -1.5328428149223328e-01</internalNodes>
<leafValues>
9.7174257040023804e-01 -7.0434033870697021e-01</leafValues></_>
<_>
<internalNodes>
0 -1 3 -1.3199757784605026e-02</internalNodes>
<leafValues>
-6.4577740430831909e-01 9.3116492033004761e-01</leafValues></_>
<_>
<internalNodes>
0 -1 8 5.8218417689204216e-04</internalNodes>
<leafValues>
-5.0572758913040161e-01 8.2068920135498047e-01</leafValues></_>
<_>
<internalNodes>
0 -1 10 -8.8631778955459595e-02</internalNodes>
<leafValues>
9.8447650671005249e-01 -4.4854977726936340e-01</leafValues></_></weakClassifiers></_>
<!-- stage 3 -->
<_>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-6.6012442111968994e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 1 -5.3001824766397476e-02</internalNodes>
<leafValues>
-6.8789541721343994e-01 1.</leafValues></_>
<_>
<internalNodes>
0 -1 7 2.3166947066783905e-02</internalNodes>
<leafValues>
7.5605052709579468e-01 -8.2546299695968628e-01</leafValues></_>
<_>
<internalNodes>
0 -1 9 -3.6986038321629167e-04</internalNodes>
<leafValues>
8.5323393344879150e-01 -6.6821050643920898e-01</leafValues></_></weakClassifiers></_>
<!-- stage 4 -->
<_>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-6.7609930038452148e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 2 -3.3533185720443726e-02</internalNodes>
<leafValues>
-8.5707658529281616e-01 1.</leafValues></_>
<_>
<internalNodes>
0 -1 12 4.2812444269657135e-02</internalNodes>
<leafValues>
1. -8.1902271509170532e-01</leafValues></_>
<_>
<internalNodes>
0 -1 5 -1.4424201846122742e-01</internalNodes>
<leafValues>
1. -7.3034769296646118e-01</leafValues></_></weakClassifiers></_></stages>
<features>
<_>
<rects>
<_>
0 0 24 22 -1.</_>
<_>
12 0 12 22 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
0 14 22 10 -1.</_>
<_>
11 14 11 10 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
2 8 18 2 -1.</_>
<_>
8 8 6 2 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
2 12 12 8 -1.</_>
<_>
8 12 6 8 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
4 0 20 23 -1.</_>
<_>
14 0 10 23 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
4 0 20 22 -1.</_>
<_>
4 11 20 11 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
6 0 18 22 -1.</_>
<_>
6 11 18 11 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
7 0 3 22 -1.</_>
<_>
7 11 3 11 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
8 3 16 3 -1.</_>
<_>
16 3 8 3 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
8 22 15 2 -1.</_>
<_>
13 22 5 2 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
10 7 12 16 -1.</_>
<_>
10 15 12 8 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
11 0 13 22 -1.</_>
<_>
11 11 13 11 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
11 1 8 9 -1.</_>
<_>
11 4 8 3 3.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
11 9 9 12 -1.</_>
<_>
11 15 9 6 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
15 1 8 22 -1.</_>
<_>
15 12 8 11 2.</_></rects>
<tilted>0</tilted></_>
<_>
<rects>
<_>
16 8 2 12 -1.</_>
<_>
16 14 2 6 2.</_></rects>
<tilted>0</tilted></_></features></cascade>
</opencv_storage>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<opencv_storage>
<params>
<stageType>BOOST</stageType>
<featureType>HAAR</featureType>
<height>24</height>
<width>24</width>
<stageParams>
<boostType>GAB</boostType>
<minHitRate>9.9500000476837158e-01</minHitRate>
<maxFalseAlarm>5.0000000000000000e-01</maxFalseAlarm>
<weightTrimRate>9.4999999999999996e-01</weightTrimRate>
<maxDepth>1</maxDepth>
<maxWeakCount>100</maxWeakCount></stageParams>
<featureParams>
<maxCatCount>0</maxCatCount>
<featSize>1</featSize>
<mode>BASIC</mode></featureParams></params>
</opencv_storage>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<opencv_storage>
<stage0>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-1.4478853940963745e+00</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 139980 -8.9639797806739807e-03</internalNodes>
<leafValues>
9.4078946113586426e-01 -8.7986546754837036e-01</leafValues></_>
<_>
<internalNodes>
0 -1 50178 -1.8076587468385696e-02</internalNodes>
<leafValues>
-5.6646192073822021e-01 9.8937672376632690e-01</leafValues></_>
<_>
<internalNodes>
0 -1 118923 -7.8208204358816147e-03</internalNodes>
<leafValues>
9.2043370008468628e-01 -6.0580855607986450e-01</leafValues></_>
<_>
<internalNodes>
0 -1 861 -3.4435594081878662e-01</internalNodes>
<leafValues>
-7.9926961660385132e-01 6.0425055027008057e-01</leafValues></_></weakClassifiers></stage0>
</opencv_storage>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<opencv_storage>
<stage1>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-7.9288864135742188e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 114982 4.9917697906494141e-02</internalNodes>
<leafValues>
8.4966927766799927e-01 -9.3601649999618530e-01</leafValues></_>
<_>
<internalNodes>
0 -1 146475 -1.1758920736610889e-03</internalNodes>
<leafValues>
7.4418127536773682e-01 -7.5894588232040405e-01</leafValues></_>
<_>
<internalNodes>
0 -1 50178 -1.0608324781060219e-02</internalNodes>
<leafValues>
-6.0105341672897339e-01 9.8875778913497925e-01</leafValues></_></weakClassifiers></stage1>
</opencv_storage>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<opencv_storage>
<stage2>
<maxWeakCount>4</maxWeakCount>
<stageThreshold>-9.7797828912734985e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 71542 -1.5328428149223328e-01</internalNodes>
<leafValues>
9.7174257040023804e-01 -7.0434033870697021e-01</leafValues></_>
<_>
<internalNodes>
0 -1 35134 -1.3199757784605026e-02</internalNodes>
<leafValues>
-6.4577740430831909e-01 9.3116492033004761e-01</leafValues></_>
<_>
<internalNodes>
0 -1 92338 5.8218417689204216e-04</internalNodes>
<leafValues>
-5.0572758913040161e-01 8.2068920135498047e-01</leafValues></_>
<_>
<internalNodes>
0 -1 110985 -8.8631778955459595e-02</internalNodes>
<leafValues>
9.8447650671005249e-01 -4.4854977726936340e-01</leafValues></_></weakClassifiers></stage2>
</opencv_storage>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<opencv_storage>
<stage3>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-6.6012442111968994e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 11364 -5.3001824766397476e-02</internalNodes>
<leafValues>
-6.8789541721343994e-01 1.</leafValues></_>
<_>
<internalNodes>
0 -1 80969 2.3166947066783905e-02</internalNodes>
<leafValues>
7.5605052709579468e-01 -8.2546299695968628e-01</leafValues></_>
<_>
<internalNodes>
0 -1 98618 -3.6986038321629167e-04</internalNodes>
<leafValues>
8.5323393344879150e-01 -6.6821050643920898e-01</leafValues></_></weakClassifiers></stage3>
</opencv_storage>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<opencv_storage>
<stage4>
<maxWeakCount>3</maxWeakCount>
<stageThreshold>-6.7609930038452148e-01</stageThreshold>
<weakClassifiers>
<_>
<internalNodes>
0 -1 32812 -3.3533185720443726e-02</internalNodes>
<leafValues>
-8.5707658529281616e-01 1.</leafValues></_>
<_>
<internalNodes>
0 -1 115411 4.2812444269657135e-02</internalNodes>
<leafValues>
1. -8.1902271509170532e-01</leafValues></_>
<_>
<internalNodes>
0 -1 50378 -1.4424201846122742e-01</internalNodes>
<leafValues>
1. -7.3034769296646118e-01</leafValues></_></weakClassifiers></stage4>
</opencv_storage>

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