Skip to content

Commit

Permalink
feature matching update
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezaahmadi committed May 20, 2022
1 parent b6ec859 commit 51c6c3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ include_directories(

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
catkin_install_python(PROGRAMS scripts/Camera.py scripts/featureExtractor.py scripts/vs_nodeHandler.py scripts/Controller.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
# catkin_install_python(PROGRAMS scripts/vs_nodeHandler.py
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
26 changes: 11 additions & 15 deletions scripts/featureMatching.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

import cv2 as cv
from matplotlib.image import BboxImage
import numpy as np
import itertools
import copy
from cv_bridge import CvBridge
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
from movingVariance import *

from shapely.geometry import Point
from shapely.geometry.polygon import Polygon
Expand Down Expand Up @@ -45,8 +42,6 @@ def detectNewCropLane(self, mode, rgbImg, greenIDx, binaryMask, wLocs, numofCrop
_rgbImg = rgbImg.copy()
# get masked rgb Image (ExG masked)
rgbMasked = self.maskRgb(rgbImg, binaryMask)
# find new crop rows and compare to old ones!

# extract keypoints and descriptors from new detected line
srcKeypoints, srcDescriptors = self.detectTrackingFeatures(rgbMasked)
# filter in desired window
Expand All @@ -56,20 +51,22 @@ def detectNewCropLane(self, mode, rgbImg, greenIDx, binaryMask, wLocs, numofCrop
# find matches between ref and src keypoints
matches = self.matchTrackingFeatures(srcKeypoints, srcDescriptors)
# if not that indicates that the window is between two lines
print(self.count, len(matches))

# draw keypoints on rgb Image
self.drawKeyPoints(_rgbImg, srcKeypoints, [0,255,0])

# collect matches
self.simDistVec = list(self.simDistVec)
self.simDistVec.append(len(matches))

# create recognition signal
peaks = []
if self.count > 110:
if self.count > 10:
# self.simDistVec = np.where(self.simDistVec > 20, np.max(self.simDistVec), self.simDistVec)
troughs, _ = find_peaks(self.simDistVec, prominence=2, height=5)
self.simDistVec = np.negative(self.simDistVec)
peaks, _ = find_peaks(self.simDistVec, prominence=2, height=-5)
# troughs, _ = find_peaks(self.simDistVec, prominence=2, height=5)
# self.simDistVec = np.negative(self.simDistVec)
# peaks, _ = find_peaks(self.simDistVec, prominence=2, height=-5)
# compute moving standard deviation
mvSignal = movingStd(self.simDistVec)
# find positive an negative peaks of the signal
peaks, troughs = findPicksTroughths(mvSignal, 0.5)
plt.plot(self.simDistVec)
pickPoses = [self.simDistVec[p] for p in peaks]
troughPoses = [self.simDistVec[p] for p in troughs]
Expand All @@ -79,7 +76,6 @@ def detectNewCropLane(self, mode, rgbImg, greenIDx, binaryMask, wLocs, numofCrop
plt.show()

self.count+=1

return (len(peaks) >= numofCropRows and len(troughs) >= numofCropRows+1)

def maskRgb(self, rgbImg, mask):
Expand Down
1 change: 0 additions & 1 deletion scripts/imageProc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def findCropRows2D(self, rgbImg):
print(
'--- Initialisation failed - No lines detected by sweeping window ---')
self.cropLaneFound = False

return lines, linesROIs

def findCropRowsInMVSignal(self, peaksPos, peaksNeg, mvSignal, lines, linesROIs):
Expand Down

0 comments on commit 51c6c3d

Please sign in to comment.