Skip to content

Commit

Permalink
Merge branch 'bugfixForVeloView4.0RC' into 'kitware-master'
Browse files Browse the repository at this point in the history
Bugfix for velo view4.0 rc

See merge request bjacquet/VeloView-kwinternal!276
  • Loading branch information
NickLaurenson committed Mar 8, 2019
2 parents 1f21bc6 + f25f29e commit ad8a2f3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 143 deletions.
1 change: 1 addition & 0 deletions VelodyneHDL/IO/Lidar/Common/vtkLidarStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ vtkLidarStream::vtkLidarStream()
//-----------------------------------------------------------------------------
vtkLidarStream::~vtkLidarStream()
{
this->Stop();
delete this->Internal;
}

Expand Down
148 changes: 38 additions & 110 deletions VelodyneHDL/python/veloview/applogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ def openSensor():
prep = smp.Show(processor)
smp.Render()

updateUIwithNewFrame()
showSourceInSpreadSheet(sensor)

app.actions['actionShowRPM'].enabled = True
Expand All @@ -455,6 +454,8 @@ def openSensor():
app.actions['actionDualReturnIntensityLow'].enabled = True
app.actions['actionRecord'].enabled = True

updateUIwithNewLidar()


def openPCAP(filename, positionFilename=None, calibrationFilename=None, calibrationUIArgs=None):

Expand Down Expand Up @@ -533,7 +534,7 @@ def onProgressEvent(o, e):
FileName=positionFilename)

posreader.GetClientSideObject().SetCalibrationTransform(calibration.gpsTransform)

smp.Show(posreader)
smp.Show(app.trailingFrame)

if positionFilename is None:
Expand Down Expand Up @@ -596,7 +597,7 @@ def onProgressEvent(o, e):
showMeasurementGrid()

smp.SetActiveSource(app.trailingFrame)
updateUIwithNewFrame()
updateUIwithNewLidar()



Expand Down Expand Up @@ -1129,6 +1130,7 @@ def close():
app.gridProperties.LineWidth = app.grid.LineWidth
app.gridProperties.Color = app.grid.Color

smp.GetAnimationScene().Stop()
hideRuler()
unloadData()
app.scene.AnimationTime = 0
Expand Down Expand Up @@ -1308,8 +1310,7 @@ def onChooseCalibrationFile():
if lidar:
lidar.Interpreter.GetClientSideObject().SetSensorTransform(sensorTransform)
lidar.CalibrationFile = calibrationFile
if getReader():
reloadCurrentFrame()
updateUIwithNewLidar()

restoreLaserSelectionDialog()

Expand Down Expand Up @@ -1522,8 +1523,9 @@ def addShortcuts(keySequenceStr, function):

def onTrailingFramesChanged(numFrames):
tr = smp.FindSource("TrailingFrame")
tr.NumberOfTrailingFrames = numFrames
smp.Render()
if tr:
tr.NumberOfTrailingFrames = numFrames
smp.Render()


def onFiringsSkipChanged(pr):
Expand Down Expand Up @@ -1622,7 +1624,7 @@ def onLaserSelectionChanged():
LidarInterpreter = getLidarPacketInterpreter()
if LidarInterpreter:
LidarInterpreter.GetClientSideObject().SetLaserSelection(mask)
reloadCurrentFrame()
smp.Render()


def hideColorByComponent():
Expand Down Expand Up @@ -1738,102 +1740,42 @@ def toggleSelectDualReturn():
return

#Get the active source
source = smp.GetActiveSource()
source = smp.FindSource("TrailingFrame")
lidarPacketInterpreter = getLidarPacketInterpreter()

#If no data are available
if not source :
return

if not lidarPacketInterpreter.GetHasDualReturn() :
if not lidarPacketInterpreter.GetClientSideObject().GetHasDualReturn() :
QtGui.QMessageBox.warning(getMainWindow(), 'Dual returns not found',
"The functionality only works with dual returns, and the current"
"frame has no dual returns.")
return

#Get the polyData which contains all points
allFrame = source.GetClientSideObject().GetOutput()
nPoints = allFrame.GetNumberOfPoints()

#Get the selected Points
selectedPoints = source.GetSelectionOutput(0)
polyData = selectedPoints.GetClientSideObject().GetOutput()
idArray = polyData.GetPointData().GetArray('dual_return_matching')
nSelectedpoints = polyData.GetNumberOfPoints()

#Select the dual return of each selected points which have a dual return
if nSelectedpoints >0 :
#create a temporary array to make a query selection
array = range(0,nPoints)

#fill the temporary array
for i in range (nPoints):
array[i] = -1

#Add the dualId in the temporary array
for i in range(nSelectedpoints):
dualId = idArray.GetValue(i)
if dualId >=0:
array[dualId] = 1

#Add the temporary array to the source
getLidarPacketInterpreter().SetSelectedPointsWithDualReturn(array,nPoints)
getLidarPacketInterpreter().SetShouldAddDualReturnArray(True)
reloadCurrentFrame()

query = 'dualReturn_of_selectedPoints>0'
smp.SelectPoints(query,source)
smp.Render()
#Tell the source the selection is made
#source.GetClientSideObject().SetShouldAddDualReturnArray(False)
#Remove the query
query = ''
#Select all the points which have a dual return if no points are selected
else :
query = 'dual_return_matching>-1'
smp.SelectPoints(query)
smp.Render()
nSelectedPoints = polyData.GetNumberOfPoints()

if nSelectedPoints > 0:
idArray = polyData.GetPointData().GetArray('dual_return_matching')
idArray = polyData.GetBlock(0).GetPointData().GetArray('dual_return_matching')
# It should be possible to filter -1 from the idArray and then just use
# np.in1d below, but doing so generates errors (either an invalid
# expression, even when handling the case of an empty array, or an
# invalid non-mask return value.
selectedDualIds = set(str(int(idArray.GetValue(i))) for i in range(nSelectedPoints))
query = 'np.logical_and(dual_return_matching > -1, np.in1d(id, [{}]))'.format(','.join(selectedDualIds))
else:
query = 'dual_return_matching > -1'
smp.SelectPoints(query)
smp.Render()


def toggleCrashAnalysis():
app.EnableCrashAnalysis = app.actions['actionEnableCrashAnalysis'].isChecked()


def toggleBirdEyeViewSnap():
# Get export images filename
fileName = getSaveFileName('Choose Output File', 'png', getDefaultSaveFileName('png'))
if not fileName:
QtGui.QMessageBox.warning(getMainWindow(), 'Invalid filename', 'Please, select a valid filename')
return

# Fit a plane using ransac algorithm
reader = getReader()
ransacPlaneFitting = smp.RansacPlaneModel(reader)
ransacPlaneFitting.GetClientSideObject().SetMaxRansacIteration(1000)
ransacPlaneFitting.GetClientSideObject().SetThreshold(0.35)
ransacPlaneFitting.GetClientSideObject().SetRatioInlierRequired(0.80)
ransacPlaneFitting.UpdatePipeline()
planeParams = range(4)
ransacPlaneFitting.GetClientSideObject().GetPlaneParam(planeParams)

# use the fitted plane to generate the bird eye view
# image (i.e: project the point cloud on the fitted plan
# and use the 2D projected point cloud to generate the image)
birdEyeViewGenerator = smp.BirdEyeViewSnap(reader)
birdEyeViewGenerator.GetClientSideObject().SetFolderName(fileName)
birdEyeViewGenerator.GetClientSideObject().SetPlaneParam(planeParams)
birdEyeViewGenerator.UpdatePipeline()

def toggleMotionDetection():
reader = getReader()

# check that a reader is available
if reader is None:
return

motionDetector = smp.MotionDetector(reader)
motionDetector.UpdatePipeline()

def setFilterToDual():
setFilterTo(0)

Expand Down Expand Up @@ -1895,16 +1837,14 @@ def fastRendererChanged():
""" Enable/Disable fast rendering by using the point cloud representation (currently only for VLS-128)
this representation hardcode the color map and their LookUpTable, which improve execution speed significantly """

source = getReader() or getSensor()
rep = smp.Show(source)
source = smp.FindSource("TrailingFrame")
if source:
rep = smp.GetRepresentation(source)

if app.actions['actionFastRenderer'].isChecked():
rep.Representation = 'Point Cloud'
else:
rep.Representation = 'Surface'

# Workaround to force the refresh for all the views
# todo
if app.actions['actionFastRenderer'].isChecked():
rep.Representation = 'Point Cloud'
else:
rep.Representation = 'Surface'

def intensitiesCorrectedChanged():
lidarInterpreter = getLidarPacketInterpreter()
Expand Down Expand Up @@ -1996,8 +1936,6 @@ def setupActions():
app.actions['actionFastRenderer'].connect('triggered()',fastRendererChanged)
app.actions['actionSelectDualReturn'].connect('triggered()',toggleSelectDualReturn)
app.actions['actionSelectDualReturn2'].connect('triggered()',toggleSelectDualReturn)
app.actions['actionBirdEyeViewSnap'].connect('triggered()', toggleBirdEyeViewSnap)
app.actions['actionMotionDetection'].connect('triggered()', toggleMotionDetection)

# Restore action states from settings
settings = getPVSettings()
Expand Down Expand Up @@ -2121,8 +2059,7 @@ def onIgnoreZeroDistances():
lidarInterpreter = getLidarPacketInterpreter()
if lidarInterpreter:
lidarInterpreter.IgnoreZeroDistances = IgnoreZeroDistances
reloadCurrentFrame()

smp.Render()

def onIntraFiringAdjust():
# Get the check box value as an int to save it into the PV settings (there's incompatibility with python booleans)
Expand All @@ -2135,7 +2072,7 @@ def onIntraFiringAdjust():
lidarInterpreter = getLidarPacketInterpreter()
if lidarInterpreter:
lidarInterpreter.UseIntraFiringAdjustment = intraFiringAdjust
reloadCurrentFrame()
smp.Render()


def onIgnoreEmptyFrames():
Expand All @@ -2149,24 +2086,15 @@ def onIgnoreEmptyFrames():
lidarInterpreter = getLidarPacketInterpreter()
if lidarInterpreter:
lidarInterpreter.IgnoreEmptyFrames = ignoreEmptyFrames
reloadCurrentFrame()


def reloadCurrentFrame():
lidar = getLidar()
if lidar:
lidar.DummyProperty = not lidar.DummyProperty
smp.Render()
smp.Render(getSpreadSheetViewProxy())
updateUIwithNewFrame()

def updateUIwithNewFrame():
def updateUIwithNewLidar():
lidar = getLidar()
if lidar:
app.sensorInformationLabel.setText(lidar.GetClientSideObject().GetSensorInformation())
#Remove some array to display
ComboBox = getMainWindow().findChild('vvColorToolbar').findChild('pqDisplayColorWidget').findChildren('QComboBox')[0]
listOfArrayToRemove = ['RotationPerMinute', 'vtkBlockColor', 'vtkCompositeIndex']
listOfArrayToRemove = ['RotationPerMinute', 'vtkBlockColors', 'vtkCompositeIndex']
for arrayName in listOfArrayToRemove:
n = ComboBox.findText(arrayName)
ComboBox.removeItem(n)
2 changes: 1 addition & 1 deletion VelodyneHDL/python/veloview/planefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def fitPlane():
smp.Show(extracter)

try:
pd = extracter.GetClientSideObject().GetOutput()
pd = extracter.GetClientSideObject().GetOutput().GetBlock(0)
max_laser_id = pd.GetPointData().GetArray("laser_id").GetRange()[1]
nchannels = 2**vtk.vtkMath.CeilLog2(int(max_laser_id))

Expand Down
2 changes: 1 addition & 1 deletion VelodyneHDL/xml/Lidar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
name="CropMode"
animateable="0"
command="SetCropMode"
default_values="1"
default_values="0"
number_of_elements="1"
panel_visibility="advanced">
<EnumerationDomain name="enum">
Expand Down
29 changes: 0 additions & 29 deletions vvMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@
<addaction name="actionIntraFiringAdjust"/>
<addaction name="actionIgnoreEmptyFrames"/>
</widget>
<widget class="QMenu" name="menuothers">
<property name="title">
<string>others...</string>
</property>
<addaction name="actionBirdEyeViewSnap"/>
<addaction name="actionMotionDetection"/>
</widget>
<addaction name="actionSpreadsheet"/>
<addaction name="actionMeasurement_Grid"/>
<addaction name="actionShowRPM"/>
Expand All @@ -129,7 +122,6 @@
<addaction name="separator"/>
<addaction name="menuDebugging"/>
<addaction name="separator"/>
<addaction name="menuothers"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
Expand Down Expand Up @@ -879,27 +871,6 @@
<string>Apply VLS-128 Fast Renderering</string>
</property>
</action>
<action name="actionBirdEyeViewSnap">
<property name="icon">
<iconset resource="vvResources.qrc">
<normaloff>:/vvResources/Icons/camera_logo.png</normaloff>:/vvResources/Icons/camera_logo.png</iconset>
</property>
<property name="text">
<string>Bird Eye View Snap</string>
</property>
<property name="toolTip">
<string>Take a snapshot of the scene in a bird eye view</string>
</property>
</action>
<action name="actionMotionDetection">
<property name="icon">
<iconset resource="vvResources.qrc">
<normaloff>:/vvResources/Icons/icon_motion.png</normaloff>:/vvResources/Icons/icon_motion.png</iconset>
</property>
<property name="text">
<string>Motion Detection</string>
</property>
</action>
<action name="actionAdvanceFeature">
<property name="checkable">
<bool>true</bool>
Expand Down
4 changes: 2 additions & 2 deletions vvPlayerControlsController.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void vvPlayerControlsController::onFirstFrame()
void vvPlayerControlsController::onPreviousFrame()
{
emit this->beginNonUndoableChanges();
SetProperty(this->Scene, "Duration", this->duration);
SetProperty(this->Scene, "PlayMode", 2);
this->Scene->getProxy()->InvokeCommand("GoToPrevious");
SM_SCOPED_TRACE(CallMethod)
.arg(this->Scene->getProxy())
Expand All @@ -237,7 +237,7 @@ void vvPlayerControlsController::onPreviousFrame()
void vvPlayerControlsController::onNextFrame()
{
emit this->beginNonUndoableChanges();
SetProperty(this->Scene, "Duration", this->duration);
SetProperty(this->Scene, "PlayMode", 2);
this->Scene->getProxy()->InvokeCommand("GoToNext");
SM_SCOPED_TRACE(CallMethod)
.arg(this->Scene->getProxy())
Expand Down

0 comments on commit ad8a2f3

Please sign in to comment.