Skip to content

Commit

Permalink
Add ability to move radiometry ROI on live display
Browse files Browse the repository at this point in the history
Grabbing roi region or clicking on the image will move the roi.
This will update the region as requested from the hardware.
  • Loading branch information
kekiefer committed Nov 30, 2018
1 parent 8178838 commit 661a519
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 13 deletions.
3 changes: 2 additions & 1 deletion inc/leptonvariation.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ class LeptonVariation : public AbstractCCInterface
Q_PROPERTY(unsigned int radSpotmeterInKelvinX100 READ getRadSpotmeterObjInKelvinX100 NOTIFY radSpotmeterInKelvinX100Changed)
unsigned int getRadSpotmeterObjInKelvinX100();

Q_PROPERTY(const QRect& radSpotmeterRoi READ getRadSpotmeterRoi NOTIFY radSpotmeterRoiChanged)
Q_PROPERTY(const QRect& radSpotmeterRoi READ getRadSpotmeterRoi WRITE setRadSpotmeterRoi NOTIFY radSpotmeterRoiChanged)
const QRect getRadSpotmeterRoi() {
return QRect(m_spotmeterRoi.startCol, m_spotmeterRoi.startRow,
m_spotmeterRoi.endCol - m_spotmeterRoi.startCol,
m_spotmeterRoi.endRow - m_spotmeterRoi.startRow);
}
void setRadSpotmeterRoi(const QRect& roi);

SDK_ENUM_PROPERTY(RAD_TLINEAR_RESOLUTION_E, radTLinearResolution, RadTLinearResolution)

Expand Down
1 change: 0 additions & 1 deletion qml/ViewerForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Item {
acq: acq
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
roi: acq.cci.radSpotmeterRoi
}
}
}
Expand Down
62 changes: 51 additions & 11 deletions qml/controls/VideoRoi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,58 @@ import GetThermal 1.0
Item {
id: root

width: parent.width
height: (parent.width * acq.videoSize.height) / acq.videoSize.width
anchors.fill: parent

property UvcAcquisition acq: null
property var roi: null

Rectangle {
x: (roi.x * parent.width) / acq.videoSize.width
y: (roi.y * parent.height) / acq.videoSize.height
width: (roi.width * parent.width) / acq.videoSize.width
height: (roi.height * parent.height) / acq.videoSize.height
color: "#80ffffff"
border.color: "#80000000"
property rect roi: acq && acq.cci ? acq.cci.radSpotmeterRoi : Qt.rect(0, 0, 80, 60)
property size videoSize: acq ? acq.videoSize : Qt.size(80, 60)

function moveUnscaledRoiTo(dispX, dispY) {
var nx = Math.floor(dispX * (videoSize.width / scaledvid.width))
var ny = Math.floor(dispY * (videoSize.height / scaledvid.height))
if (roi.x === nx && roi.y === ny) {
return
}
acq.cci.radSpotmeterRoi = Qt.rect(nx, ny, roi.width, roi.height)
}

Item {
id: scaledvid

width: root.width
height: (root.width * videoSize.height) / videoSize.width
anchors.centerIn: root

MouseArea {
cursorShape: Qt.CrossCursor
anchors.fill: parent
onClicked: {
moveUnscaledRoiTo(mouse.x, mouse.y)
}
}

Rectangle {
id: roidisp

x: roi.x * (scaledvid.width / videoSize.width)
y: roi.y * (scaledvid.height / videoSize.height)
width: roi.width * (scaledvid.width / videoSize.width)
height: roi.height * (scaledvid.height / videoSize.height)

color: "#80ffffff"
border.color: "#80000000"

MouseArea {
cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.OpenHandCursor
anchors.fill: parent
drag.target: roidisp
drag.axis: Drag.XAndYAxis
drag.smoothed: false
drag.threshold: 1
onPositionChanged: {
moveUnscaledRoiTo(roidisp.x, roidisp.y)
}
}
}
}
}
18 changes: 18 additions & 0 deletions src/leptonvariation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ unsigned int LeptonVariation::getRadSpotmeterObjInKelvinX100()
return 0;
}

void LeptonVariation::setRadSpotmeterRoi(const QRect& roi)
{
LEP_RAD_ROI_T newSpot = {
static_cast<unsigned short>(roi.y()),
static_cast<unsigned short>(roi.x()),
static_cast<unsigned short>(roi.y() + roi.height()),
static_cast<unsigned short>(roi.x() + roi.width())
};

if (LEP_SetRadSpotmeterRoi(&m_portDesc, newSpot) != LEP_OK) {
printf("LEP_SetRadSpotmeterRoi failed");
return;
}

m_spotmeterRoi = newSpot;
emit radSpotmeterRoiChanged();
emit radSpotmeterInKelvinX100Changed();
}

void LeptonVariation::performFfc()
{
Expand Down

0 comments on commit 661a519

Please sign in to comment.