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