Definition at line 20 of file PointDescriptorIO.h. References ILOG_DEBUG, ILOG_ERROR, ILOG_VAR, Impala::Core::Matrix::MatE(), Impala::Core::Matrix::MatNrCol(), Impala::Core::Matrix::MatNrRow(), and Impala::Util::IOBuffer::Write(). Referenced by Impala::Core::Feature::PointDescriptorTable::ExportToFile(). 00021 { 00022 ILOG_VAR(Core.Feature.PointDescriptorIO.WriteBINDESC1ToBuffer); 00023 00024 using namespace Impala::Core::Matrix; 00025 /* Format BINDESC1 00026 ----------------------- 00027 First 8 bytes: BINDESC1 00028 Second 8 bytes: data type (CIRCLE is typical) 00029 Next 16 bytes: 4 integers: 00030 elementsPerPoint = values[0] 00031 dimensionCount = values[1] 00032 pointCount = values[2] 00033 bytesPerElement = values[3] 00034 */ 00035 int elementsPerPoint = MatNrCol(points); 00036 int dimensionCount = 0; 00037 int pointCount = MatNrRow(points); 00038 int bytesPerElement = 8; 00039 00040 if(descriptors) 00041 { 00042 if(MatNrRow(descriptors) > 0) 00043 { 00044 dimensionCount = MatNrCol(descriptors); 00045 if(MatNrRow(descriptors) != pointCount) 00046 { 00047 ILOG_ERROR("Dimension mismatch in points/descriptors: " << 00048 pointCount << " " << MatNrRow(descriptors)); 00049 } 00050 } 00051 } 00052 00053 String magic = "BINDESC1"; 00054 String dataType = "UNKNOWN "; 00055 if(theDataType.size() == 8) 00056 { 00057 dataType = theDataType; 00058 } 00059 else 00060 { 00061 ILOG_ERROR("Coding error: your datatype specification should be 8 bytes long"); 00062 } 00063 00064 ILOG_DEBUG("Writing header..."); 00065 buffer->Write(magic.c_str(), 8); 00066 buffer->Write(dataType.c_str(), 8); 00067 buffer->Write(&elementsPerPoint, 4); 00068 buffer->Write(&dimensionCount, 4); 00069 buffer->Write(&pointCount, 4); 00070 buffer->Write(&bytesPerElement, 4); 00071 ILOG_DEBUG("Wrote full header"); 00072 00073 for(int i = 0; i < pointCount; i++) 00074 { 00075 buffer->Write(MatE(points, i, 0), sizeof(Real64) * elementsPerPoint); 00076 } 00077 00078 if(dimensionCount == 0) return; 00079 00080 for(int i = 0; i < pointCount; i++) 00081 { 00082 buffer->Write(MatE(descriptors, i , 0), sizeof(Real64) * dimensionCount); 00083 } 00084 }
Here is the call graph for this function:
|