From a98dbb0f8774259792c297883f753444b797bf2f Mon Sep 17 00:00:00 2001 From: Daniel Aharoni Date: Thu, 16 Jul 2020 21:11:51 -0700 Subject: [PATCH] Add commands to request a specific resolution when connecting to a DAQ. Add initial MiniLFM support. These changes need to be used along with the newest versions of the Miniscope DAQ firmware which now support a range of devices with a single firmware build. --- deviceConfigs/miniscopes.json | 167 +++++++++++++++++++++ source/videostreamocv.cpp | 4 + userConfigs/UserConfigExample_MiniLFM.json | 54 +++++++ 3 files changed, 225 insertions(+) create mode 100644 userConfigs/UserConfigExample_MiniLFM.json diff --git a/deviceConfigs/miniscopes.json b/deviceConfigs/miniscopes.json index 5bdeda1..68b2faf 100644 --- a/deviceConfigs/miniscopes.json +++ b/deviceConfigs/miniscopes.json @@ -1035,5 +1035,172 @@ } ] + }, + "MiniLFM": { + "qmlFile": "qrc:/Miniscope_V4_BNO.qml", + "sensor": "MT9P031", + "frameRate": "adjustable", + "width": 2592, + "height": 1944, + "headOrientation": false, + "isColor": false, + "controlSettings": { + "gain": { + "displaySpinBoxValues":["Low", "Medium", "High"], + "displayTextValues": [1, 4, 8], + "outputValues":[8,32,96], + "startValue": "Low", + "sendCommand": [ + { + "protocol": "I2C", + "addressW": "0xBA", + "regLength": "1", + "reg0": "0x35", + "dataLength": "2", + "data0": "valueH", + "data1": "valueL" + } + ] + }, + "frameRate": { + "displaySpinBoxValues":["10FPS", "15FPS", "20FPS"], + "displayTextValues": [10, 15, 20], + "outputValues":[2048,1536,1024], + "startValue": "20FPS", + "sendCommand": [ + { + "protocol": "I2C", + "addressW": "0xBA", + "regLength": "1", + "reg0": "0x09", + "dataLength": "2", + "data0": "valueH", + "data1": "valueL" + } + ] + }, + "led0": { + "startValue": 0, + "min": 0, + "max": 100, + "stepSize": 1, + "displayValueScale": -2.55, + "displayValueOffset": -255, + "sendCommand": [ + { + "protocol": "I2C", + "addressW": "0b01011000", + "regLength": "1", + "reg0": "0x00", + "dataLength": "2", + "data0": "value", + "data1": "value" + } + ] + }, + "ewl": { + "startValue": 0, + "min": -127, + "max": 127, + "stepSize": 1, + "displayValueScale": 1, + "displayValueOffset": -127, + "sendCommand": [ + { + "protocol": "I2C", + "addressW": "0b11101110", + "regLength": "1", + "reg0": "0x08", + "dataLength": "2", + "data0": "value", + "data1": "0x02" + } + ] + } + }, + "initialize": [ + { + "description": "Speed up i2c bus timer to 50us max", + "protocol": "I2C", + "addressW": "0xC0", + "regLength": "1", + "reg0": "0x22", + "dataLength": "1", + "data0": "0b00000010" + }, + { + "description": "Decrease BCC timeout, units in 2ms XX", + "protocol": "I2C", + "addressW": "0xC0", + "regLength": "1", + "reg0": "0x20", + "dataLength": "1", + "data0": "0b00001010" + }, + { + "description": "Make sure DES has SER ADDR", + "protocol": "I2C", + "addressW": "0xC0", + "regLength": "1", + "reg0": "0x07", + "dataLength": "1", + "data0": "0xB0" + }, + { + "description": "Speed up I2c bus timer to 50u Max", + "protocol": "I2C", + "addressW": "0xB0", + "regLength": "1", + "reg0": "0x0F", + "dataLength": "1", + "data0": "0b00000010" + }, + { + "description": "Decrease BCC timeout, units in 2ms", + "protocol": "I2C", + "addressW": "0xB0", + "regLength": "1", + "reg0": "0x1E", + "dataLength": "1", + "data0": "0b00001010" + }, + { + "description": "sets allowable i2c addresses to send through serializer", + "protocol": "I2C", + "addressW": "0xC0", + "regLength": "1", + "reg0": "0x08", + "dataLength": "3", + "device0": "MT9P031", + "data0": "0xBA", + "device1": "EWL Driver", + "data1": "0b11101110", + "device2": "Digital Pot", + "data2": "0b10100000" + }, + { + "description": "sets sudo allowable i2c addresses to send through serializer", + "protocol": "I2C", + "addressW": "0xC0", + "regLength": "1", + "reg0": "0x10", + "dataLength": "3", + "device0": "MT9P031", + "data0": "0xBA", + "device1": "EWL Driver", + "data1": "0b11101110", + "device2": "Digital Pot Sudo", + "data2": "0b01011000" + }, + { + "description": "Enable EWL Driver", + "protocol": "I2C", + "addressW": "0b11101110", + "regLength": "1", + "reg0": "0x03", + "dataLength": "1", + "data0": "0x03" + } + ] } } diff --git a/source/videostreamocv.cpp b/source/videostreamocv.cpp index b219c71..0aa8d85 100644 --- a/source/videostreamocv.cpp +++ b/source/videostreamocv.cpp @@ -62,6 +62,10 @@ int VideoStreamOCV::connect2Camera(int cameraID) { m_connectionType = "OTHER"; } } + if (connectionState != 0) { + cam->set(cv::CAP_PROP_FRAME_WIDTH, m_expectedWidth); + cam->set(cv::CAP_PROP_FRAME_HEIGHT, m_expectedHeight); + } // qDebug() << "Camera capture backend is" << QString::fromStdString (cam->getBackendName()); return connectionState; diff --git a/userConfigs/UserConfigExample_MiniLFM.json b/userConfigs/UserConfigExample_MiniLFM.json new file mode 100644 index 0000000..244e817 --- /dev/null +++ b/userConfigs/UserConfigExample_MiniLFM.json @@ -0,0 +1,54 @@ +{ + "researcherName": "Dr_Miniscope", + "dataDirectory": "C:/Users/DBAharoni/Documents/Data", + "reserved terms for directoryStructure": ["time", "date"], + "directoryStructure": [ + "researcherName", + "experimentName", + "animalID", + "date", + "time" + ], + "animalName": "testMouse", + "animalID": "ID42", + "experimentName": "Linear Track Test", + "test": "TEST", + "recordLengthinSeconds": 0, + "experiment_Not_Implemented": { + "type": "linearTrack", + "units": "cm", + "trackLength": 200 + }, + "behaviorTracker_Not_Implemented": { + "type": "HSV", + "hue": [0, 1], + "saturation": [0, 1], + "value": [0, 1] + }, + "devices": { + "miniscopes": [ + { + "deviceName": "Miniscope", + "deviceType": "MiniLFM", + "imageRegistration": "Off", + "headOrientation": { + "enable": false, + "filterBadData": true + }, + "streamHeadOrientation_OLD": false, + "deviceID": 1, + "showSaturation": true, + "compressionOptions": ["MJPG","MJ2C","XVID","FFV1"], + "compression": "FFV1", + "framesPerFile": 1000, + "windowScale": 0.75, + "windowX": 800, + "windowY": 100, + "gain": "Low", + "ewl": 50, + "led0": 10, + "frameRate": "10FPS" + } + ] + } +}