Save Fault Info to Database
This commit is contained in:
@@ -57,7 +57,7 @@ void FaultManager::StartGPS()
|
|||||||
gps->startUpdates();
|
gps->startUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaultManager::SaveImage()
|
void FaultManager::SaveImage(QByteArray *imageBuffer)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
|
|
||||||
@@ -65,14 +65,17 @@ void FaultManager::SaveImage()
|
|||||||
QGeoPositionInfo position = gps->lastKnownPosition(true);
|
QGeoPositionInfo position = gps->lastKnownPosition(true);
|
||||||
QGeoCoordinate coorinate = position.coordinate();
|
QGeoCoordinate coorinate = position.coordinate();
|
||||||
|
|
||||||
qInfo() << coorinate.isValid();
|
query.prepare("INSERT INTO Faults (latitude, longitude, altitude, image) "
|
||||||
qInfo() << coorinate.longitude();
|
"VALUES (:latitude, :longitude, :altitude, :image)");
|
||||||
qInfo() << coorinate.latitude();
|
if (coorinate.isValid())
|
||||||
qInfo() << coorinate.altitude();
|
{
|
||||||
|
// This probably wont work without proper converstions
|
||||||
// Save Image to Filesystem
|
query.bindValue(":latitude", coorinate.latitude());
|
||||||
//QSaveFile
|
query.bindValue(":longitude", coorinate.longitude());
|
||||||
|
query.bindValue(":altitude", coorinate.altitude());
|
||||||
|
}
|
||||||
|
query.bindValue(":image", *imageBuffer);
|
||||||
|
|
||||||
// Save to Database
|
// Save to Database
|
||||||
//query.exec("INSERT");
|
query.exec();
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ class FaultManager: public QObject
|
|||||||
public:
|
public:
|
||||||
FaultManager(QObject *parent);
|
FaultManager(QObject *parent);
|
||||||
virtual ~FaultManager();
|
virtual ~FaultManager();
|
||||||
void SaveImage();
|
void SaveImage(QByteArray *imageBuffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OpenDatabase();
|
bool OpenDatabase();
|
||||||
|
|||||||
@@ -76,8 +76,14 @@ void ImageManager::ProcessImage(int width, int height, uint8_t *imgPointer)
|
|||||||
|
|
||||||
if (area > fault_area)
|
if (area > fault_area)
|
||||||
{
|
{
|
||||||
drawContours(viewfinder, contours, i, Scalar(ZERO, BITS8, ZERO), 2);
|
// Fault Detected, Draw on Screen and Save to Database
|
||||||
((FaultFinder*)(parent()))->fault_mgr->SaveImage();
|
drawContours(viewfinder, contours, i, Scalar(ZERO, BITS8, ZERO), 2);
|
||||||
|
|
||||||
|
std::vector<uchar> imageBuffer;
|
||||||
|
imencode("pgm", frame, imageBuffer);
|
||||||
|
QByteArray* imageBytes = new QByteArray(reinterpret_cast<const char*>(imageBuffer.data()), imageBuffer.size());
|
||||||
|
|
||||||
|
((FaultFinder*)(parent()))->fault_mgr->SaveImage(imageBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user