Skip to content

Commit

Permalink
Add available codec display in main window
Browse files Browse the repository at this point in the history
  • Loading branch information
daharoni committed Feb 4, 2020
1 parent bda94f8 commit 8bcd3c1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
45 changes: 44 additions & 1 deletion source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include <QDir>
#include <QVector>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>

#include "miniscope.h"
#include "behaviorcam.h"
#include "controlpanel.h"
Expand Down Expand Up @@ -50,7 +56,15 @@ backEnd::backEnd(QObject *parent) :
ucBehaviorTracker["type"] = "None";

dataSaver = new DataSaver();
setUserConfigDisplay("Select a User Configuration file.");


testCodecSupport();
QString tempStr;
for (int i = 0; i < availableCodec.length(); i++)
tempStr += availableCodec[i] + ", ";

setUserConfigDisplay("Select a User Configuration file.\nAvailable Codecs on your computer are:\n" + tempStr);

// QObject::connect(this, SIGNAL (userConfigFileNameChanged()), this, SLOT( handleUserConfigFileNameChanged() ));
}

Expand Down Expand Up @@ -209,6 +223,32 @@ void backEnd::setupDataSaver()
dataSaverThread->start();
}

void backEnd::testCodecSupport()
{
// This function will test which codecs are supported on host's machine
cv::VideoWriter testVid;
QVector<QString> possibleCodec({"DIB ", "MJPG", "MJ2C", "XVID", "FFV1"});

testVid.open("test.raw", 0, 0, cv::Size(640, 480), true);
if (testVid.isOpened()) {
qDebug() << "RAWAWAWAWAW";
testVid.release();
}
else
qDebug() << "NOOOOOOO GOOOOOOOOD";

for (int i = 0; i < possibleCodec.length(); i++) {
testVid.open("test.avi", cv::VideoWriter::fourcc(possibleCodec[i].toStdString()[0],possibleCodec[i].toStdString()[1],possibleCodec[i].toStdString()[2],possibleCodec[i].toStdString()[3]),
20, cv::Size(640, 480), true);
if (testVid.isOpened()) {
availableCodec.append(possibleCodec[i]);
qDebug() << "Codec" << possibleCodec[i] << "supported for color";
testVid.release();
}
}

}

bool backEnd::checkUserConfigForIssues()
{
if (checkForUniqueDeviceNames() == false) {
Expand Down Expand Up @@ -294,6 +334,9 @@ void backEnd::constructUserConfigGUI()

// Load main control GUI
controlPanel = new ControlPanel(this, m_userConfig);
QObject::connect(this, SIGNAL (sendMessage(QString) ), controlPanel, SLOT( receiveMessage(QString)));



for (idx = 0; idx < ucMiniscopes.size(); idx++) {
miniscope.append(new Miniscope(this, ucMiniscopes[idx].toObject()));
Expand Down
5 changes: 5 additions & 0 deletions source/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class backEnd : public QObject
void userConfigOKChanged();
void closeAll();
void showErrorMessage();
void sendMessage(QString);

public slots:
void onRunClicked();
Expand All @@ -60,6 +61,8 @@ public slots:
void connectSnS();
void setupDataSaver();

void testCodecSupport();

QString m_userConfigFileName;
QString m_userConfigDisplay;
bool m_userConfigOK;
Expand Down Expand Up @@ -87,6 +90,8 @@ public slots:

BehaviorTracker *behavTracker;

QVector<QString> availableCodec;

};

#endif // BACKEND_H

0 comments on commit 8bcd3c1

Please sign in to comment.