• 大小: 44KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: 其他
  • 标签: 图像分类  

资源简介

图像分类,基于opencv进行图图像分类工作的。可以完美运行。

资源截图

代码片段和文件信息

#>>>>>>>>	   Cutting Border Functions	      <<<<<<<<<<#
# Cordeiro Libel - UTFPR - 2017        #
#-------------------------------------------------------#

#My libraries
from commons import *

# Find the largest contour
def largestCnt(contours):
area = 0
largest_cnt = 0

for cnt in contours:
cnt_area = cv2.contourArea(cnt)
if cnt_area > area:
area = cnt_area
largest_cnt = cnt
return largest_cnt

#   Simplify points in 4 points  O(sqrt(n)) n:number of points
#Calculate the best four points is expensive.
#So we indenfy the best points in a samples of all points.
#As soon we look around this sample and find the best point.
# . . . . . . . . . . . .
# ^         ^         ^ 
# |__jump___|__jump___|
def findCorner(pointsx_maxy_max):
four_points = np.array([[00][00][00][00]])

size = points.size/2

#the cost function is C(samples) = samples+2*jump-1 for jump = (size-1)/samples
#the minimal of the cost is dC(samples)/dsamples = 1-2*(size-1)*samples^-2 = 0 so samples = 1+sqrt(2*(size-1))
#samples: number of samples for the aproximate the minimal and maximal element
samples = toInt(np.sqrt(2*(size-1)))
jump = 1.0*(size-1)/samples

#====The first look (2 points)
amin = 1000000
amax = -1000000
for i in range(samples+1): 
index = toInt(i*jump)
val = points[index][0]+points[index][1]
if val #save point closer NW vertice
n_min = index
amin = val
if val>amax:
#save point closer SE vertice
n_max = index
amax = val
four_points[0] = points[n_min]
four_points[3] = points[n_max]

#====The Second look (2 points) around the n_min and n_max
for i in range(toInt(2*jump)-1):
index = (n_min - toInt(jump) + 1 + i)%size
val = points[index][0]+points[index][1]
if val #save point closer NW vertice
four_points[0] = points[index]
amin = val

index = (n_max - toInt(jump) + 1 + i)%size
val = points[index][0]+points[index][1]
if val>amax:
#save point closer SE vertice
four_points[3] = points[index]
amax = val

#====The first look (more 2 points)
amin = 1000000
amax = -1000000
for i in range(samples+1): 
index = toInt(i*jump)
val = points[index][0]-points[index][1]
if val #save point closer SW vertice
n_min = index
amin = val
if val>amax:
#save point closer NE vertice
n_max = index
amax = val
four_points[2] = points[n_min]
four_points[1] = points[n_max]

#====The Second look (2 points) around the n_min and n_max
for i in range(toInt(2*jump)-1):
index = (n_min - toInt(jump) + 1 + i)%size
val = points[index][0]-points[index][1]
if val #save point closer SW vertice
four_points[2] = points[index]
amin = val

index = (n_max - toInt(jump) + 1 + i)%size
val = points[index][0]-points[index][1]
if val>amax:
#save point closer NE vertice
four_points[1] = points[index]
amax = val

return four_points

def cutBorder(img fix_size = True size = SIDE inv = False draw = Falsefour_points = None return_four_

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-09-25 22:53  imgClassification-master\
     文件          37  2017-09-25 22:53  imgClassification-master\.gitignore
     文件         415  2017-09-25 22:53  imgClassification-master\README.md
     文件        4750  2017-09-25 22:53  imgClassification-master\border.py
     文件        2456  2017-09-25 22:53  imgClassification-master\camera.py
     文件        3219  2017-09-25 22:53  imgClassification-master\classify.py
     文件        5497  2017-09-25 22:53  imgClassification-master\commons.py
     文件        1063  2017-09-25 22:53  imgClassification-master\dadosLoad.py
     文件        2385  2017-09-25 22:53  imgClassification-master\dadosSave.py
     文件        8572  2017-09-25 22:53  imgClassification-master\identify.py
     文件        3927  2017-09-25 22:53  imgClassification-master\interface.py
     文件        1284  2017-09-25 22:53  imgClassification-master\main.py
     文件        2361  2017-09-25 22:53  imgClassification-master\main2.py
     文件         902  2017-09-25 22:53  imgClassification-master\photos.py
     文件         594  2017-09-25 22:53  imgClassification-master\randImgs.py
     文件        6814  2017-09-25 22:53  imgClassification-master\servo.py
     文件        3367  2017-09-25 22:53  imgClassification-master\set_servos.py
     文件        2336  2017-09-25 22:53  imgClassification-master\test_servos.py
     文件       61636  2017-09-25 22:53  imgClassification-master\treino.out

评论

共有 条评论