Fixed fx=0 error when running multi-session databases

This commit is contained in:
matlabbe
2016-11-16 12:28:33 -05:00
parent d73394abd8
commit 8560baca87
2 changed files with 17 additions and 1 deletions

View File

@@ -602,6 +602,7 @@ bool DBDriver::getCalibration(
std::vector<CameraModel> & models, std::vector<CameraModel> & models,
StereoCameraModel & stereoModel) const StereoCameraModel & stereoModel) const
{ {
UDEBUG("");
bool found = false; bool found = false;
// look in the trash // look in the trash
_trashesMutex.lock(); _trashesMutex.lock();

View File

@@ -1062,6 +1062,7 @@ void DBDriverSqlite3::loadNodeDataQuery(std::list<Signature *> & signatures, boo
} }
else if(uStrNumCmp(_version, "0.7.0") >= 0) else if(uStrNumCmp(_version, "0.7.0") >= 0)
{ {
UDEBUG("Loading calibration version >= 0.7.0");
double fx = sqlite3_column_double(ppStmt, index++); double fx = sqlite3_column_double(ppStmt, index++);
double fyOrBaseline = sqlite3_column_double(ppStmt, index++); double fyOrBaseline = sqlite3_column_double(ppStmt, index++);
double cx = sqlite3_column_double(ppStmt, index++); double cx = sqlite3_column_double(ppStmt, index++);
@@ -1078,6 +1079,7 @@ void DBDriverSqlite3::loadNodeDataQuery(std::list<Signature *> & signatures, boo
} }
else else
{ {
UDEBUG("Loading calibration version < 0.7.0");
float depthConstant = sqlite3_column_double(ppStmt, index++); float depthConstant = sqlite3_column_double(ppStmt, index++);
float fx = 1.0f/depthConstant; float fx = 1.0f/depthConstant;
float fy = 1.0f/depthConstant; float fy = 1.0f/depthConstant;
@@ -1269,7 +1271,7 @@ bool DBDriverSqlite3::getCalibrationQuery(
const void * data = 0; const void * data = 0;
int dataSize = 0; int dataSize = 0;
Transform localTransform; Transform localTransform = Transform::getIdentity();
// Process the result if one // Process the result if one
rc = sqlite3_step(ppStmt); rc = sqlite3_step(ppStmt);
@@ -1279,6 +1281,16 @@ bool DBDriverSqlite3::getCalibrationQuery(
int index = 0; int index = 0;
// calibration // calibration
if(uStrNumCmp(_version, "0.10.0") < 0)
{
data = sqlite3_column_blob(ppStmt, index); // local transform
dataSize = sqlite3_column_bytes(ppStmt, index++);
if((unsigned int)dataSize == localTransform.size()*sizeof(float) && data)
{
memcpy(localTransform.data(), data, dataSize);
}
}
if(uStrNumCmp(_version, "0.10.0") >= 0) if(uStrNumCmp(_version, "0.10.0") >= 0)
{ {
data = sqlite3_column_blob(ppStmt, index); data = sqlite3_column_blob(ppStmt, index);
@@ -1351,10 +1363,12 @@ bool DBDriverSqlite3::getCalibrationQuery(
} }
else if(uStrNumCmp(_version, "0.7.0") >= 0) else if(uStrNumCmp(_version, "0.7.0") >= 0)
{ {
UDEBUG("Loading calibration version >= 0.7.0");
double fx = sqlite3_column_double(ppStmt, index++); double fx = sqlite3_column_double(ppStmt, index++);
double fyOrBaseline = sqlite3_column_double(ppStmt, index++); double fyOrBaseline = sqlite3_column_double(ppStmt, index++);
double cx = sqlite3_column_double(ppStmt, index++); double cx = sqlite3_column_double(ppStmt, index++);
double cy = sqlite3_column_double(ppStmt, index++); double cy = sqlite3_column_double(ppStmt, index++);
UDEBUG("fx=%f fyOrBaseline=%f cx=%f cy=%f", fx, fyOrBaseline, cx, cy);
if(fyOrBaseline < 1.0) if(fyOrBaseline < 1.0)
{ {
//it is a baseline //it is a baseline
@@ -1367,6 +1381,7 @@ bool DBDriverSqlite3::getCalibrationQuery(
} }
else else
{ {
UDEBUG("Loading calibration version < 0.7.0");
float depthConstant = sqlite3_column_double(ppStmt, index++); float depthConstant = sqlite3_column_double(ppStmt, index++);
float fx = 1.0f/depthConstant; float fx = 1.0f/depthConstant;
float fy = 1.0f/depthConstant; float fy = 1.0f/depthConstant;