車牌識別
用python3+opencv3做的中國車牌識別,包括算法和客戶端界面,只有2個文件,一個是界面代碼,一個是算法代碼,點擊即可出結(jié)果,方便易用!
鏈接:車牌識別
大致的UI界面如下,點擊輸入圖片,右側(cè)即可出現(xiàn)結(jié)果!
代碼
額外說明:算法代碼只有500行,測試中發(fā)現(xiàn),車牌定位算法的參數(shù)受圖像分辨率、色偏、車距影響。
--->qq 1309399183----------<代碼交流
def from_pic(self):
self.thread_run = False
self.pic_path = askopenfilename(title="選擇識別圖片", filetypes=[("jpg圖片", "*.jpg")])
if self.pic_path:
img_bgr = predict.imreadex(self.pic_path)
self.imgtk = self.get_imgtk(img_bgr)
self.image_ctl.configure(image=self.imgtk)
resize_rates = (1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)
for resize_rate in resize_rates:
print("resize_rate:", resize_rate)
r, roi, color = self.predictor.predict(img_bgr, resize_rate)
if r:
break
#r, roi, color = self.predictor.predict(img_bgr, 1)
self.show_roi(r, roi, color)
圖像去霧去雨+目標(biāo)檢測+單目測距結(jié)合
實時感知本車周圍物體的距離對高級駕駛輔助系統(tǒng)具有重要意義,當(dāng)判定物體與本車距離小于安
鏈接:單目測距
全距離時便采取主動剎車等安全輔助功能,這將進(jìn)一步提升汽車的安全性能并減少碰撞的發(fā)生。上一章本文完成了目標(biāo)檢測任務(wù),接下來需要對檢測出來的物體進(jìn)行距離測量。
- 首先描述并分析了相機成像模型,推導(dǎo)了圖像的像素坐標(biāo)系與世界坐標(biāo)系之間的關(guān)系。
- 其次,利用軟件標(biāo)定來獲取相機內(nèi)外參數(shù)并改進(jìn)了測距目標(biāo)點的選取。
- 最后利用測距模型完成距離的測量并對采集到的圖像進(jìn)行仿真分析和方法驗證。
代碼
for path, img, im0s, vid_cap in dataset:
img = torch.from_numpy(img).to(device)
img = img.half() if half else img.float() # uint8 to fp16/32
img /= 255.0 # 0 - 255 to 0.0 - 1.0
if img.ndimension() == 3:
img = img.unsqueeze(0)
# Warmup
if device.type != 'cpu' and (old_img_b != img.shape[0] or old_img_h != img.shape[2] or old_img_w != img.shape[3]):
old_img_b = img.shape[0]
old_img_h = img.shape[2]
old_img_w = img.shape[3]
for i in range(3):
model(img, augment=opt.augment)[0]
# Inference
t1 = time_synchronized()
with torch.no_grad(): # Calculating gradients would cause a GPU memory leak
pred = model(img, augment=opt.augment)[0]
t2 = time_synchronized()
distance=object_point_world_position(u, v, h, w, out_mat, in_mat):
路徑規(guī)劃
本節(jié)針對越野場景路徑規(guī)劃問題,采用柵格法建立障礙物、威脅物和越野道路模型,模擬真實的越野環(huán)境場景。
-
引入方向變化懲罰和局部區(qū)域復(fù)雜度懲罰來優(yōu)化A算法,使算法規(guī)劃出的路徑更平滑,算法效率更高效。
-
采用改進(jìn) Floyd 算法對路徑進(jìn)行雙向平滑,并且進(jìn)行了防碰撞處理,來確保規(guī)劃出路徑的安全可靠性。
-
仿真結(jié)果表明,所改進(jìn)的 A算法與傳統(tǒng)算法相比較,效率提高了 30%,拐點數(shù)減少了4
倍,所提算法能夠在越野環(huán)境多重因素綜合影響以及不同車輛性能和任務(wù)的要求下快速的規(guī)劃出安全的路徑。
代碼
###############創(chuàng)建A-Star類############
class AStar:
# 描述AStar算法中的節(jié)點數(shù)據(jù)
class Node:
#初始化
def __init__(self, point, startPoint,endPoint, g=0,w=1,p=1):
self.point = point # 自己的坐標(biāo)
self.father = None # 父節(jié)點
self.g = g # g值,g值在用到的時候會重新算
# 計算h值,采用曼哈頓距離
#self.h = (abs(endPoint.x - point.x) + abs(endPoint.y - point.y)) * 10
#采用歐幾里得距離
#self.h = math.pow((math.pow((endPoint.x - point.x),2) + math.pow((endPoint.y - point.y),2)),0.5)*10
#采用對角距離
pp=(1-p)+0.2*math.exp((math.pow((math.pow((endPoint.x - point.x),2) + math.pow((endPoint.y - point.y),2)),0.5))/(math.pow((math.pow((endPoint.x - startPoint.x),2) + math.pow((endPoint.y - startPoint.y),2)),0.5)))
Diagonal_step = min((endPoint.x - point.x),(endPoint.y - point.y))
straight_step = (abs(endPoint.x - point.x) + abs(endPoint.y - point.y)) - 2*Diagonal_step
self.h =(straight_step + math.pow(2,0.5)*Diagonal_step)*10*pp
#print(pp)
#初始化A-start
def __init__(self, map2d, startPoint, endPoint, passTag=1.0):#map2d地圖信息,startPoint起點, endPoint終點, passTag=1.0為不可行駛區(qū)域
# 開啟表
self.openList = []
# 關(guān)閉表
self.closeList = []
# 尋路地圖
self.map2d = map2d
# 起點終點
if isinstance(startPoint, Point) and isinstance(endPoint, Point):
self.startPoint = startPoint
self.endPoint = endPoint
else:
self.startPoint = Point(*startPoint)
self.endPoint = Point(*endPoint)
# 不可行走標(biāo)記
self.passTag = passTag
def getMinNode(self):
"""
獲得openlist中F值最小的節(jié)點
:return: Node
"""
currentNode = self.openList[0]
for node in self.openList:
if node.g + node.h < currentNode.g + currentNode.h:
currentNode = node
return currentNode#返回最小代價的點
停車位檢測
基于深度學(xué)習(xí)的魚眼圖像中的停車點檢測和分類是為二維物體檢測而開發(fā)的。我們的工作增強了預(yù)測關(guān)鍵點和方框的能力。這在許多場景中很有用,因為對象不能用右上的矩形“緊密”表示。
一個這樣的例子,道路上的任何標(biāo)記,由于透視效果,在現(xiàn)實世界中的對象矩形不會在圖像中保持矩形,所以關(guān)鍵點檢測顯得格外重要。魚眼圖像還呈現(xiàn)了觀察到這種現(xiàn)象的另一種場景,由于魚眼寬廣的視角,可以撲捉更多畫像
鏈接:停車位檢測
代碼
#全部代碼可加qq1309399183
def train():
#parses command line args
args = parse_args()
#parses args from file
if args.config_file is not None:
cfg_from_file(args.config_file)
if (args.FIX_MODEL_CHECKPOINT):
args.FIX_MODEL_CHECKPOINT = args.FIX_MODEL_CHECKPOINT.replace(" ", "")
args.FIX_MODEL_CHECKPOINT = args.FIX_MODEL_CHECKPOINT.replace("=", "")
cfg.RESUME_CHECKPOINT = args.FIX_MODEL_CHECKPOINT
cfg.CHECK_PREVIOUS = False
if (os.path.exists(cfg.RESUME_CHECKPOINT) == False):
print('Exiting the process as asked model for resuming is not found')
exit()
if (args.RESUME_CHECKPOINT):
cfg.RESUME_CHECKPOINT = args.RESUME_CHECKPOINT
if (args.LOG_DIR):
cfg.EXP_DIR = args.LOG_DIR
cfg.LOG_DIR = cfg.EXP_DIR
if (args.PHASE):
cfg.PHASE = []
cfg.PHASE.append(args.PHASE)
if (args.EVAL_METHOD):
cfg.DATASET.EVAL_METHOD = args.EVAL_METHOD
#for backward compatibility
if cfg.DATASET.DATASET == 'psd':
cfg.DATASET.DATASET = 'tiod'
if cfg.DATASET.BGR_OR_RGB == True:
#cfg.DATASET.PIXEL_MEANS = (123.68, 116.78, 103.94)
#cfg.DATASET.PIXEL_MEANS = (123, 117, 104)
cfg.DATASET.PIXEL_MEANS = (128.0, 128.0, 128.0) # simpler mean subtraction to keep data in int8 after mean subtraction
print("cfg: ", cfg)
for phase in cfg.PHASE:
cfg_dir = cfg.LOG_DIR + '/' + phase + '_cfg/'
os.makedirs(os.path.dirname(cfg_dir), exist_ok=True)
shutil.copy(args.config_file, cfg_dir)
# to making every run consistent # TII
np.random.seed(100)
torch.manual_seed(100)
torch.cuda.manual_seed(100)
random.seed(100)
torch.cuda.manual_seed_all(999)
torch.backends.cudnn.enabled = False
train_model()
if __name__ == '__main__':
train()
圖像霧去雨與目標(biāo)檢測
針對不同的天氣則采取不同的圖像前處理方法來提升圖像質(zhì)量。霧天天氣 時,針對當(dāng)下求解的透射率會導(dǎo)致去霧結(jié)果出現(xiàn)光暈、偽影現(xiàn)象,本文采用加權(quán)最小二乘法細(xì)化透射率透。針對四叉樹法得到的大氣光值不精確的問題,改進(jìn)四叉樹法來解決上述問題。將上述得到的透射率和大氣光值代入大氣散射模型完成去霧處理;
在圖像處理后加入目標(biāo)檢測,提高了目標(biāo)檢測精度以及目標(biāo)數(shù)量。
下圖展現(xiàn)了霧天處理后的結(jié)果
圖第一列為霧霾圖像,第二列為沒有加入圖像處理的目標(biāo)檢測結(jié)果圖,第三列為去霧后的目標(biāo)檢測結(jié)果圖。文章來源:http://www.zghlxwxcb.cn/news/detail-723127.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-723127.html
到了這里,關(guān)于計算機視覺實戰(zhàn)項目2(單目測距+圖像處理+路徑規(guī)劃+車牌識別)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!