From 67406252febce967b3caf27f24038c295f3860d6 Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Wed, 9 Sep 2020 17:44:54 -0700 Subject: [PATCH 1/5] Fix V4 LED not turning off when set to 0 in GUI --- deviceConfigs/miniscopes.json | 2 +- source/main.cpp | 2 +- userConfigs/UserConfigExample_V4_BNO_Miniscope.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deviceConfigs/miniscopes.json b/deviceConfigs/miniscopes.json index e1b6f31..2b956b6 100644 --- a/deviceConfigs/miniscopes.json +++ b/deviceConfigs/miniscopes.json @@ -54,7 +54,7 @@ "max": 100, "stepSize": 1, "displayValueScale": -2.55, - "displayValueOffset": 0, + "displayValueOffset": -255, "sendCommand": [ { "protocol": "I2C", diff --git a/source/main.cpp b/source/main.cpp index 8694615..27299d7 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,7 +9,7 @@ #include "backend.h" -#define VERSION_NUMBER "1.00" +#define VERSION_NUMBER "1.01" // TODO: have exit button close everything // For Window's deployment diff --git a/userConfigs/UserConfigExample_V4_BNO_Miniscope.json b/userConfigs/UserConfigExample_V4_BNO_Miniscope.json index 56abaab..33601ba 100644 --- a/userConfigs/UserConfigExample_V4_BNO_Miniscope.json +++ b/userConfigs/UserConfigExample_V4_BNO_Miniscope.json @@ -36,7 +36,7 @@ "filterBadData": true }, "streamHeadOrientation_OLD": true, - "deviceID": 0, + "deviceID": 1, "showSaturation": true, "compressionOptions": ["MJPG","MJ2C","XVID","FFV1"], "compression": "FFV1", From fa48f3fc18b256c0fc0634c5044fde739262fef1 Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Thu, 10 Sep 2020 19:04:02 -0700 Subject: [PATCH 2/5] Fix bug where behavior video would save with 0KB when ROI wasn't defined. --- source/behaviorcam.cpp | 25 +++++++++++++++++------ userConfigs/UserConfigExample_WebCam.json | 7 ++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/source/behaviorcam.cpp b/source/behaviorcam.cpp index aadb094..d1f2204 100644 --- a/source/behaviorcam.cpp +++ b/source/behaviorcam.cpp @@ -32,10 +32,10 @@ BehaviorCam::BehaviorCam(QObject *parent, QJsonObject ucBehavCam) : m_ucBehavCam = ucBehavCam; // hold user config for this Miniscope - parseUserConfigBehavCam(); - getBehavCamConfig(m_ucBehavCam["deviceType"].toString()); // holds specific Miniscope configuration + parseUserConfigBehavCam(); + // TODO: Handle cases where there is more than webcams and MiniCAMs if (m_ucBehavCam["deviceType"].toString() == "WebCam") { isMiniCAM = false; @@ -220,10 +220,14 @@ void BehaviorCam::parseUserConfigBehavCam() { m_roiBoundingBox[1] = m_ucBehavCam["ROI"].toObject()["topEdge"].toInt(-1); m_roiBoundingBox[2] = m_ucBehavCam["ROI"].toObject()["width"].toInt(-1); m_roiBoundingBox[3] = m_ucBehavCam["ROI"].toObject()["height"].toInt(-1); - - // TODO: Throw error is values are incorrect or missing } + else { + m_roiBoundingBox[0] = 0; + m_roiBoundingBox[1] = 0; + m_roiBoundingBox[2] = m_cBehavCam["width"].toInt(-1); + m_roiBoundingBox[3] = m_cBehavCam["height"].toInt(-1); + } } void BehaviorCam::sendInitCommands() @@ -605,19 +609,28 @@ void BehaviorCam::handleSetRoiClicked() void BehaviorCam::handleNewROI(int leftEdge, int topEdge, int width, int height) { + m_roiIsDefined = true; // First scale the local position values to pixel values m_roiBoundingBox[0] = round(leftEdge/m_ucBehavCam["windowScale"].toDouble(1)); m_roiBoundingBox[1] = round(topEdge/m_ucBehavCam["windowScale"].toDouble(1)); m_roiBoundingBox[2] = round(width/m_ucBehavCam["windowScale"].toDouble(1)); m_roiBoundingBox[3] = round(height/m_ucBehavCam["windowScale"].toDouble(1)); + if ((m_roiBoundingBox[0] + m_roiBoundingBox[2]) > m_cBehavCam["width"].toInt(-1)) { + // Edge is off screen + m_roiBoundingBox[2] = m_cBehavCam["width"].toInt(-1) - m_roiBoundingBox[0]; + } + if ((m_roiBoundingBox[1] + m_roiBoundingBox[3]) > m_cBehavCam["height"].toInt(-1)) { + // Edge is off screen + m_roiBoundingBox[3] = m_cBehavCam["height"].toInt(-1) - m_roiBoundingBox[1]; + } + sendMessage("ROI Set to [" + QString::number(m_roiBoundingBox[0]) + ", " + QString::number(m_roiBoundingBox[1]) + ", " + QString::number(m_roiBoundingBox[2]) + ", " + QString::number(m_roiBoundingBox[3]) + "]"); - // TODO: Make sure ROI gets saved in meta data - // TODO: enable ROI button + // TODO: Correct ROI if out of bounds } diff --git a/userConfigs/UserConfigExample_WebCam.json b/userConfigs/UserConfigExample_WebCam.json index 50c1f06..41a1e43 100644 --- a/userConfigs/UserConfigExample_WebCam.json +++ b/userConfigs/UserConfigExample_WebCam.json @@ -1,6 +1,6 @@ { "researcherName": "Dr_Miniscope", - "dataDirectory": "C:/Users/DBAharoni/Documents/Data", + "dataDirectory": "C:/Users/dbaha/Documents/Data", "directoryStructure": [ "researcherName", "experimentName", @@ -30,7 +30,8 @@ "deviceID": 0, "showSaturation": true, "ROI": { - "notes": "This defines the bounding box of the portion of the video that is saved to disk", + "notes": "This defines the bounding box of the portion of the video that is saved to disk", + "note3": "Edge values are zero indexed", "leftEdge": 10, "topEdge": 20, "width": 300, @@ -38,7 +39,7 @@ }, "cameraCalibrationFileLocation": "", "compressionOptions": ["MJPG","MJ2C","XVID","FFV1"], - "compression": "FFV1", + "compression": "MJPG", "framesPerFile": 1000, "windowScale": 0.75, "windowX": 800, From 92881930861673d26d313aa95ecd37e89432ade0 Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Thu, 10 Sep 2020 19:28:42 -0700 Subject: [PATCH 3/5] Add additional webcam resolutions. Add warning if ROI extends out of bounds. --- deviceConfigs/behaviorCams.json | 28 ++++++++++++++++++++++- source/behaviorcam.cpp | 6 +++-- userConfigs/UserConfigExample_WebCam.json | 10 ++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/deviceConfigs/behaviorCams.json b/deviceConfigs/behaviorCams.json index 2e18a3d..36d5cc0 100644 --- a/deviceConfigs/behaviorCams.json +++ b/deviceConfigs/behaviorCams.json @@ -8,7 +8,33 @@ "controlSettings": { } }, - + "WebCam-320x240": { + "sensor": "", + "frameRate": 30, + "width": 320, + "height": 240, + "isColor": true, + "controlSettings": { + } + }, + "WebCam-640x480": { + "sensor": "", + "frameRate": 30, + "width": 640, + "height": 480, + "isColor": true, + "controlSettings": { + } + }, + "WebCam-1280x720": { + "sensor": "", + "frameRate": 30, + "width": 1280, + "height": 720, + "isColor": true, + "controlSettings": { + } + }, "Minicam-Mono-XGA": { "qmlFile": "qrc:/behaviorCam.qml", "sensor": "MT9P031", diff --git a/source/behaviorcam.cpp b/source/behaviorcam.cpp index d1f2204..705a718 100644 --- a/source/behaviorcam.cpp +++ b/source/behaviorcam.cpp @@ -37,7 +37,7 @@ BehaviorCam::BehaviorCam(QObject *parent, QJsonObject ucBehavCam) : parseUserConfigBehavCam(); // TODO: Handle cases where there is more than webcams and MiniCAMs - if (m_ucBehavCam["deviceType"].toString() == "WebCam") { + if (m_ucBehavCam["deviceType"].toString().toLower().contains("webcam")) { isMiniCAM = false; m_daqFrameNum = nullptr; } @@ -289,7 +289,6 @@ void BehaviorCam::getBehavCamConfig(QString deviceType) { QJsonDocument d = QJsonDocument::fromJson(jsonFile.toUtf8()); QJsonObject jObj = d.object(); m_cBehavCam = jObj[deviceType].toObject(); - } void BehaviorCam::configureBehavCamControls() { @@ -619,10 +618,13 @@ void BehaviorCam::handleNewROI(int leftEdge, int topEdge, int width, int height) if ((m_roiBoundingBox[0] + m_roiBoundingBox[2]) > m_cBehavCam["width"].toInt(-1)) { // Edge is off screen m_roiBoundingBox[2] = m_cBehavCam["width"].toInt(-1) - m_roiBoundingBox[0]; + sendMessage("Warning: Right edge of ROI drawn beyond right edge of video. If this is incorrect you can change the width and height values in deviceCnfigs/behaviorCams.json"); } if ((m_roiBoundingBox[1] + m_roiBoundingBox[3]) > m_cBehavCam["height"].toInt(-1)) { // Edge is off screen m_roiBoundingBox[3] = m_cBehavCam["height"].toInt(-1) - m_roiBoundingBox[1]; + sendMessage("Warning: Bottm edge of ROI drawn beyond bottom edge of video. If this is incorrect you can change the width and height values in deviceCnfigs/behaviorCams.json"); + } sendMessage("ROI Set to [" + QString::number(m_roiBoundingBox[0]) + ", " + diff --git a/userConfigs/UserConfigExample_WebCam.json b/userConfigs/UserConfigExample_WebCam.json index 41a1e43..db70d64 100644 --- a/userConfigs/UserConfigExample_WebCam.json +++ b/userConfigs/UserConfigExample_WebCam.json @@ -26,16 +26,16 @@ "cameras": [ { "deviceName": "BehavCam 0", - "deviceType": "WebCam", + "deviceType": "WebCam-1280x720", "deviceID": 0, "showSaturation": true, "ROI": { "notes": "This defines the bounding box of the portion of the video that is saved to disk", "note3": "Edge values are zero indexed", - "leftEdge": 10, - "topEdge": 20, - "width": 300, - "height": 200 + "leftEdge": 0, + "topEdge": 0, + "width": 640, + "height": 480 }, "cameraCalibrationFileLocation": "", "compressionOptions": ["MJPG","MJ2C","XVID","FFV1"], From efe2d3ad8a10a97f3efbfbe7605b127fa7eac598 Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Thu, 10 Sep 2020 19:29:33 -0700 Subject: [PATCH 4/5] Update version number --- source/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/main.cpp b/source/main.cpp index 27299d7..83bf7d0 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,7 +9,7 @@ #include "backend.h" -#define VERSION_NUMBER "1.01" +#define VERSION_NUMBER "1.02" // TODO: have exit button close everything // For Window's deployment From a802a0f0414f77921cedee4e43fa09df09c51259 Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Thu, 10 Sep 2020 19:35:41 -0700 Subject: [PATCH 5/5] Add test to direct users to deviceConfig folder for more device info. --- source/backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/backend.cpp b/source/backend.cpp index a27a9cb..791a014 100644 --- a/source/backend.cpp +++ b/source/backend.cpp @@ -167,7 +167,7 @@ backEnd::backEnd(QObject *parent) : for (int i = 0; i < unAvailableCodec.length(); i++) tempStr += unAvailableCodec[i] + ", "; - setUserConfigDisplay("Select a User Configuration file.\n\nAvailable compression Codecs on your computer are:\n" + m_availableCodecList + + setUserConfigDisplay("Select a User Configuration file.\n\nSupported devices are listed in the .json files in the deviceConfig folder.\n\nAvailable compression Codecs on your computer are:\n" + m_availableCodecList + "\n\nUnavailable compression Codes on your computer are:\n" + tempStr.chopped(2)); // QObject::connect(this, SIGNAL (userConfigFileNameChanged()), this, SLOT( handleUserConfigFileNameChanged() ));