Changeset 31928 for trunk/ippToPsps/src/Dvo.c
- Timestamp:
- Jul 25, 2011, 12:31:14 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/Dvo.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/Dvo.c
r31265 r31928 27 27 Gets detections for this imageid 28 28 */ 29 static bool getDetections(Dvo* this , int32_t sourceId, int32_t imageId) {29 static bool getDetections(Dvo* this) { 30 30 31 31 SkyList* skyList = NULL; 32 32 Image* image = NULL; 33 this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database...\n"); 34 skyList = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, &image); 35 if (!skyList) { 36 37 this->logger->print(this->logger, MSG_ERROR, 38 "Dvo", "Could not find skylist for sourceId=%d and image ID = %d\n", 39 sourceId, imageId); 40 41 return false; 42 } 43 this->logger->print(this->logger, MSG_INFO, "Dvo", "...done\n"); 44 45 // now get detections 46 this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting detections...\n"); 47 dvoDetection* dvoDetections = NULL; 48 int32_t maxDetectionId = -1; 49 int32_t numDetections = 50 dvoGetDetections(skyList, image->imageID, &dvoDetections, &maxDetectionId); 51 52 this->logger->print(this->logger, MSG_INFO, "Dvo", 53 "Found %d detections with a max detection ID of %d\n", 54 numDetections, maxDetectionId); 55 56 if (dvoDetections) dvoFree(dvoDetections); 57 SkyListFree(skyList); 58 59 this->logger->print(this->logger, MSG_INFO, "Dvo", "Deleting everything from dvo table\n"); 60 mysql_query(this->mysql, "DELETE FROM dvo"); 61 62 this->logger->print(this->logger, MSG_INFO, "Dvo", "Inserting IDs into dvo table...\n"); 63 33 34 this->logger->print(this->logger, MSG_INFO, "Dvo", "Deleting everything from the dvoDetection table\n"); 35 mysql_query(this->mysql, "DELETE FROM dvoDetection"); 36 37 mysql_query(this->mysql, "SELECT sourceID, imageID FROM dvoMeta"); 38 MYSQL_RES* result = mysql_store_result(this->mysql); 39 40 // loop through all souceID/imageIDs 41 MYSQL_ROW row; 64 42 char sql[500]; 65 for (int i=0; i<numDetections; i++) { 43 int sourceID, imageID; 44 while ((row = mysql_fetch_row(result))) { 45 46 sourceID = atoi(row[0]); 47 imageID = atoi(row[1]); 48 49 this->logger->print(this->logger, MSG_INFO, "Dvo", "---------------------------------------------------------------------\n"); 50 this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database for source ID = %d and image ID = %d\n", 51 sourceID, imageID); 52 skyList = dvoSkyListByExternID(this->dvoConfig, sourceID, imageID, &image); 53 if (!skyList) { 54 55 this->logger->print(this->logger, MSG_ERROR, 56 "Dvo", "Could not find skylist for sourceId=%d and image ID = %d\n", 57 sourceID, imageID); 58 59 continue; 60 } 66 61 67 62 sprintf(sql, 68 " INSERT INTO dvo (ippDetectID, ippObjID, objID) VALUES (%u, %lu, %lu)",69 dvoDetections[i].meas.detID,70 (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID,71 dvoDetections[i].ave.extID);72 63 "UPDATE dvoMeta SET flags = %d, photcode = %d WHERE sourceID = %d AND imageID = %d", 64 image->flags, 65 image->photcode, 66 sourceID, 67 imageID); 73 68 mysql_query(this->mysql, sql); 74 } 75 this->logger->print(this->logger, MSG_INFO, "Dvo", "...done\n"); 76 77 #if 0 78 mysql_query(this->mysql, "SELECT * FROM Filter"); 79 MYSQL_RES* result = mysql_store_result(this->mysql); 80 81 int num_fields = mysql_num_fields(result); 82 83 MYSQL_ROW row; 84 85 while ((row = mysql_fetch_row(result))) { 86 87 for(int i = 0; i < num_fields; i++) { 88 89 printf("%s ", row[i] ? row[i] : "NULL"); 69 70 // now get detections 71 this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting detections...\n"); 72 dvoDetection* dvoDetections = NULL; 73 int32_t maxDetectionId = -1; 74 int32_t numDetections = 75 dvoGetDetections(skyList, image->imageID, &dvoDetections, &maxDetectionId); 76 77 this->logger->print(this->logger, MSG_INFO, "Dvo", 78 "Found %d detections with a max detection ID of %d\n", 79 numDetections, maxDetectionId); 80 81 82 this->logger->print(this->logger, MSG_INFO, "Dvo", "Inserting IDs into dvoDetection table...\n"); 83 84 uint32_t zeroDvoCount = 0; 85 for (int i=0; i<maxDetectionId+1; i++) { 86 87 if (dvoDetections[i].ave.extID == 0) { 88 zeroDvoCount++; 89 } 90 else { 91 sprintf(sql, 92 "INSERT INTO dvoDetection (sourceID, imageID, ippDetectID, detectID, ippObjID, objID, flags) VALUES (%d, %d, %u, %lu, %lu, %lu, %u)", 93 sourceID, // sourceID 94 imageID, // imageID 95 dvoDetections[i].meas.detID, // ippDetectID 96 dvoDetections[i].meas.extID, // detectID 97 (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID, // ippObjID 98 dvoDetections[i].ave.extID, // objID 99 dvoDetections[i].meas.dbFlags); // flags 100 101 mysql_query(this->mysql, sql); 102 } 90 103 } 91 printf("\n"); 104 105 if (zeroDvoCount) this->logger->print(this->logger, MSG_ERROR, "Dvo", "Found %d 0 object IDs\n", zeroDvoCount); 106 if (dvoDetections) dvoFree(dvoDetections); 107 SkyListFree(skyList); 92 108 } 93 109 94 110 mysql_free_result(result); 95 #endif 111 96 112 return true; 97 113 } … … 106 122 this->logger->print(this->logger, MSG_DEBUG, "Dvo", "Constructor\n"); 107 123 108 const char *configFile = " jython/config.xml";124 const char *configFile = "./config.xml"; // TODO hardcoded path to config 109 125 this->logger->print(this->logger, MSG_INFO, "Dvo", "Using config file here '%s'\n", configFile); 110 126 xmlDoc* doc = xmlReadFile(configFile, NULL, 0); … … 202 218 } 203 219 204 205 220 /** 206 221 Main … … 210 225 Logger* logger = new_Logger(NULL, true); 211 226 212 Dvo * dvo = new_Dvo(logger, "/data/ipp004.0/gpc1/catdirs/ThreePi.V1"); 213 dvo->getDetections(dvo, 33, 8345290); 214 dvo->destroy(dvo); 227 if (argc < 2) { 228 229 logger->print(logger, MSG_ERROR, "Dvo", "Incorrect arguments\n"); 230 logger->print(logger, MSG_INFO, "Dvo", "Usage: ./dvo <pathToDvo>\n"); 231 } 232 else { 233 //Dvo * dvo = new_Dvo(logger, "/data/ipp004.0/gpc1/catdirs/ThreePi.V1"); 234 Dvo * dvo = new_Dvo(logger, argv[1]); 235 //dvo->getDetections(dvo, 33, 8345290); 236 dvo->getDetections(dvo); 237 dvo->destroy(dvo); 238 } 215 239 216 240 logger->destroy(logger);
Note:
See TracChangeset
for help on using the changeset viewer.
