Changeset 32337 for branches/eam_branches/ipp-20110710/ippToPsps/src/Dvo.c
- Timestamp:
- Sep 6, 2011, 11:00:22 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/ippToPsps/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/ippToPsps/src
- Property svn:ignore
-
old new 5 5 *.lo 6 6 *.la 7 ippToPsps8 7 config.h 9 8 config.h.in 10 9 stamp-h1 11 10 VersionDefinitions.h 12 detectionbatch 13 initbatch 14 stackbatch 15 11 dvograbber
-
- Property svn:ignore
-
branches/eam_branches/ipp-20110710/ippToPsps/src/Dvo.c
r31265 r32337 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, externID 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, externID; 44 while ((row = mysql_fetch_row(result))) { 45 46 sourceID = atoi(row[0]); 47 externID = 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 extern ID = %d\n", 51 sourceID, externID); 52 skyList = dvoSkyListByExternID(this->dvoConfig, sourceID, externID, &image); 53 if (!skyList) { 54 55 this->logger->print(this->logger, MSG_ERROR, 56 "Dvo", "Could not find skylist for sourceId=%d and extern ID = %d\n", 57 sourceID, externID); 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 imageID = %d,flags = %d, photcode = %d WHERE sourceID = %d AND externID = %d", 64 image->imageID, 65 image->flags, 66 image->photcode, 67 sourceID, 68 externID); 73 69 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"); 70 71 // now get detections 72 this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting detections...\n"); 73 dvoDetection* dvoDetections = NULL; 74 int32_t maxDetectionId = -1; 75 int32_t numDetections = 76 dvoGetDetections(skyList, image->imageID, &dvoDetections, &maxDetectionId); 77 78 this->logger->print(this->logger, MSG_INFO, "Dvo", 79 "Found %d detections with a max detection ID of %d\n", 80 numDetections, maxDetectionId); 81 82 83 this->logger->print(this->logger, MSG_INFO, "Dvo", "Inserting IDs into dvoDetection table...\n"); 84 85 uint32_t zeroDvoCount = 0; 86 for (int i=0; i<maxDetectionId+1; i++) { 87 88 if (dvoDetections[i].ave.extID == 0) { 89 zeroDvoCount++; 90 } 91 else { 92 sprintf(sql, 93 "INSERT INTO dvoDetection (sourceID, imageID, ippDetectID, detectID, ippObjID, objID, flags) VALUES (%d, %d, %u, %lu, %lu, %lu, %u)", 94 sourceID, // sourceID 95 image->imageID, // imageID 96 dvoDetections[i].meas.detID, // ippDetectID 97 dvoDetections[i].meas.extID, // detectID 98 (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID, // ippObjID 99 dvoDetections[i].ave.extID, // objID 100 dvoDetections[i].meas.dbFlags); // flags 101 102 mysql_query(this->mysql, sql); 103 } 90 104 } 91 printf("\n"); 105 106 if (zeroDvoCount) this->logger->print(this->logger, MSG_ERROR, "Dvo", "Found %d 0 object IDs\n", zeroDvoCount); 107 if (dvoDetections) dvoFree(dvoDetections); 108 SkyListFree(skyList); 92 109 } 93 110 94 111 mysql_free_result(result); 95 #endif 112 96 113 return true; 97 114 } … … 100 117 Constructor. 101 118 */ 102 Dvo* new_Dvo(Logger* logger, const char* dvoDatabase) {119 Dvo* new_Dvo(Logger* logger, const char* configFile, const char* dvoDatabase) { 103 120 104 121 Dvo* this = (Dvo*)calloc(1, sizeof(Dvo)); … … 106 123 this->logger->print(this->logger, MSG_DEBUG, "Dvo", "Constructor\n"); 107 124 108 const char *configFile = "jython/config.xml";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 < 3) { 228 229 logger->print(logger, MSG_ERROR, "Dvo", "Incorrect arguments\n"); 230 logger->print(logger, MSG_INFO, "Dvo", "Usage: ./dvo <pathToConfig> <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], argv[2]); 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.
