[tracks] movement of window should work
This commit is contained in:
parent
1d6e25dc3d
commit
a4e0529c86
@ -116,11 +116,6 @@ class DetectionView(QWidget):
|
||||
else:
|
||||
super().wheelEvent(event)
|
||||
|
||||
# elif modifiers == Qt.ShiftModifier:
|
||||
# print("Shift key pressed")
|
||||
# elif modifiers == Qt.AltModifier:
|
||||
# print("Alt key pressed")
|
||||
|
||||
def setImage(self, image: QImage):
|
||||
self._img = image
|
||||
self._scene.signals.itemsSelected.connect(self.on_itemSelection)
|
||||
@ -152,7 +147,7 @@ class DetectionView(QWidget):
|
||||
item.setData(DetectionData.COORDINATES.value, coordinates[i, :, :])
|
||||
item.setData(DetectionData.FRAME.value, frames[i])
|
||||
item = self._scene.addItem(item)
|
||||
logging.debug("DetectionView: Number of items in scene: %i", len(self._scene.items()))
|
||||
# logging.debug("DetectionView: Number of items in scene: %i", len(self._scene.items()))
|
||||
|
||||
def fit_image_to_view(self):
|
||||
"""Scale the image to fit the QGraphicsView."""
|
||||
|
@ -171,6 +171,9 @@ class FixTracks(QWidget):
|
||||
self._reader = None
|
||||
self._image = None
|
||||
self._clear_detections = True
|
||||
self._currentWindowPos = 0 # in frames
|
||||
self._currentWindowWidth = 0 # in frames
|
||||
self._maxframes = 0
|
||||
self._data = TrackingData()
|
||||
self._brushes = {"assigned_left": QBrush(QColor.fromString("orange")),
|
||||
"assigned_right": QBrush(QColor.fromString("green")),
|
||||
@ -199,6 +202,7 @@ class FixTracks(QWidget):
|
||||
self._windowspinner.setSingleStep(50)
|
||||
self._windowspinner.setValue(500)
|
||||
self._windowspinner.valueChanged.connect(self.on_windowSizeChanged)
|
||||
# self._timeline.setWindowWidth(0.01)
|
||||
self._keypointcombo = QComboBox()
|
||||
self._keypointcombo.currentIndexChanged.connect(self.on_keypointSelected)
|
||||
|
||||
@ -307,12 +311,9 @@ class FixTracks(QWidget):
|
||||
frames = df["frame"].values.astype(int)
|
||||
self._detectionView.addDetections(coords, tracks, ids, frames, keypoint, self._brushes[name])
|
||||
|
||||
max_frames = self._data.max("frame")
|
||||
start = self._timeline.rangeStart
|
||||
stop = self._timeline.rangeStop
|
||||
start_frame = int(np.floor(start * max_frames))
|
||||
stop_frame = int(np.ceil(stop * max_frames))
|
||||
logging.debug("Updating View for detection range %i, %i frames", start_frame, stop_frame)
|
||||
start_frame = self._currentWindowPos
|
||||
stop_frame = start_frame + self._currentWindowWidth
|
||||
logging.debug("Tracks:update: Updating View for detection range %i, %i frames", start_frame, stop_frame)
|
||||
self._data.setSelectionRange("frame", start_frame, stop_frame)
|
||||
frames = self._data.selectedData("frame")
|
||||
tracks = self._data.selectedData("track")
|
||||
@ -340,19 +341,16 @@ class FixTracks(QWidget):
|
||||
@fileList.setter
|
||||
def fileList(self, file_list):
|
||||
logging.debug("FixTracks.fileList: set new file list")
|
||||
print(file_list)
|
||||
self._files = []
|
||||
self._image_combo.clear()
|
||||
self._data_combo.clear()
|
||||
|
||||
logging.debug("FixTracks.fileList: setting image combo box")
|
||||
img_formats = [".jpg", ".png"]
|
||||
self._files = [str(f) for f in file_list if f.suffix in img_formats]
|
||||
self._image_combo.addItem("Please select")
|
||||
self._image_combo.addItems(self.fileList)
|
||||
self._image_combo.setCurrentIndex(0)
|
||||
|
||||
logging.debug("FixTracks.fileList: setting data combo box")
|
||||
dataformats = [".pkl"]
|
||||
self._files = [str(f) for f in file_list if f.suffix in dataformats]
|
||||
self._data_combo.addItem("Please select")
|
||||
@ -366,17 +364,18 @@ class FixTracks(QWidget):
|
||||
self._keypointcombo.setCurrentIndex(0)
|
||||
|
||||
def _on_dataOpenend(self, state):
|
||||
logging.info("Finished loading data with state %s", state)
|
||||
self._tasklabel.setText("")
|
||||
self._progress_bar.setRange(0, 100)
|
||||
self._progress_bar.setValue(0)
|
||||
if state and self._reader is not None:
|
||||
self._data.setData(self._reader.asdict)
|
||||
self._currentWindowPos = 0
|
||||
self._currentWindowWidth = self._windowspinner.value()
|
||||
self._maxframes = self._data.max("frame")
|
||||
self.populateKeypointCombo(self._data.numKeypoints())
|
||||
self._timeline.setDetectionData(self._data.data)
|
||||
maxframes = self._data.max("frame")
|
||||
rel_width = self._windowspinner.value() / maxframes
|
||||
self._timeline.setWindowWidth(rel_width)
|
||||
self._timeline.setWindow(self._currentWindowPos / self._maxframes,
|
||||
self._currentWindowWidth / self._maxframes)
|
||||
coordinates = self._data.coordinates()
|
||||
positions = self._data.centerOfGravity()
|
||||
tracks = self._data["track"]
|
||||
@ -385,6 +384,7 @@ class FixTracks(QWidget):
|
||||
self._classifier.neighborhood_validator.setData(positions, tracks, frames)
|
||||
self.update()
|
||||
self._saveBtn.setEnabled(True)
|
||||
logging.info("Finished loading data: %i frames, %i detections", self._maxframes, len(positions))
|
||||
|
||||
def on_keypointSelected(self):
|
||||
self.update()
|
||||
@ -433,6 +433,7 @@ class FixTracks(QWidget):
|
||||
|
||||
def on_windowChanged(self):
|
||||
logging.info("Timeline reports window change ")
|
||||
self._currentWindowPos = np.round(self._timeline.rangeStart * self._maxframes)
|
||||
self.update()
|
||||
|
||||
def on_windowSizeChanged(self, value):
|
||||
@ -443,10 +444,9 @@ class FixTracks(QWidget):
|
||||
value : int
|
||||
The width of the observation window in frames.
|
||||
"""
|
||||
max_frames = self._data.max("frame")
|
||||
rel_width = value / max_frames
|
||||
logging.debug("Tracks:OnWindowSizeChanged %f", rel_width)
|
||||
self._timeline.setWindowWidth(rel_width)
|
||||
self._currentWindowWidth = value
|
||||
logging.debug("Tracks:OnWindowSizeChanged %i franes", value)
|
||||
self._timeline.setWindowWidth(self._currentWindowWidth / self._maxframes)
|
||||
|
||||
def on_detectionsSelected(self, detections):
|
||||
logging.debug("Tracks: Detections selected")
|
||||
@ -470,11 +470,11 @@ class FixTracks(QWidget):
|
||||
self.update()
|
||||
|
||||
def moveWindow(self, stepsize):
|
||||
max_frames = self._data.max("frame")
|
||||
self._clear_detections = True
|
||||
step = stepsize * (self._windowspinner.value() / max_frames)
|
||||
newx = self._timeline.rangeStart + step
|
||||
self._timeline.setWindowPos(newx)
|
||||
step = np.round(stepsize * (self._currentWindowWidth))
|
||||
new_start_frame = self._currentWindowPos + step
|
||||
self._timeline.setWindowPos(new_start_frame / self._maxframes)
|
||||
self._currentWindowPos = new_start_frame
|
||||
self.update()
|
||||
|
||||
def on_forward(self, stepsize):
|
||||
|
Loading…
Reference in New Issue
Block a user