Definition at line 75 of file InterestPointListIO.h. References Impala::Core::Vector::VectorTem< ElemT >::GetData(), ILOG_DEBUG, ILOG_ERROR, ILOG_VAR, Impala::Core::Vector::VectorTem< ElemT >::Size(), and Impala::Util::IOBuffer::Write(). Referenced by WritePointListToFile(). 00076 { 00077 ILOG_VAR(Sandbox.koen.WriteRegionsToBuffer); 00078 /* Format BINDESC1 00079 ----------------------- 00080 First 8 bytes: BINDESC1 00081 Second 8 bytes: data type (CIRCLE is typical) 00082 Next 16 bytes: 4 integers: 00083 elementsPerPoint = values[0] 00084 dimensionCount = values[1] 00085 pointCount = values[2] 00086 bytesPerElement = values[3] 00087 */ 00088 int elementsPerPoint = 0; 00089 int dimensionCount = 0; 00090 int pointCount = outputPointList.size(); 00091 int bytesPerElement = 8; 00092 00093 String magic = "BINDESC1"; 00094 String dataType = "UNKNOWN "; 00095 String geometry = ""; 00096 if(outputPointList.size() > 0) 00097 { 00098 Core::Vector::VectorTem<Real64>* p = (*(outputPointList.begin()))->PointAsVector(borderOffset+1, borderOffset+1); 00099 elementsPerPoint = p->Size(); 00100 delete p; 00101 00102 dimensionCount = (*(outputPointList.begin()))->mDescriptor.size(); 00103 geometry = (*(outputPointList.begin()))->geometryType(); 00104 if(geometry == "CircleZ") 00105 { 00106 dataType = "CIRCLE "; 00107 } 00108 else if(geometry == "RectangleZ") 00109 { 00110 dataType = "RECT "; 00111 } 00112 } 00113 if(!writeDescriptors) dimensionCount = 0; 00114 00115 ILOG_DEBUG("Writing header..."); 00116 buffer->Write(magic.c_str(), 8); 00117 buffer->Write(dataType.c_str(), 8); 00118 buffer->Write(&elementsPerPoint, 4); 00119 buffer->Write(&dimensionCount, 4); 00120 buffer->Write(&pointCount, 4); 00121 buffer->Write(&bytesPerElement, 4); 00122 ILOG_DEBUG("Wrote full header"); 00123 00124 for(InterestPointList::iterator iter = outputPointList.begin(); iter != outputPointList.end(); iter++) 00125 { 00126 InterestPoint* point = *iter; 00127 // shift by 1 for consistency with the public file format (which uses 1..n instead of 0..n-1) 00128 // make coordinates equal to the original image, without the borders removed 00129 Core::Vector::VectorTem<Real64>* p = point->PointAsVector(borderOffset+1, borderOffset+1); 00130 if(p->Size() != elementsPerPoint) 00131 { 00132 ILOG_ERROR("Point representations do not have equal length!"); 00133 return; 00134 } 00135 buffer->Write(p->GetData(), sizeof(Real64) * elementsPerPoint); 00136 delete p; 00137 } 00138 00139 if(dimensionCount == 0) return; 00140 00141 Core::Vector::VectorTem<Real64> v = Core::Vector::VectorTem<Real64>(dimensionCount); 00142 for(InterestPointList::iterator iter = outputPointList.begin(); iter != outputPointList.end(); iter++) 00143 { 00144 InterestPoint* point = *iter; 00145 if(point->mDescriptor.size() != dimensionCount) 00146 { 00147 ILOG_ERROR("Your code has created descriptors with variable length!"); 00148 } 00149 for(int i = 0; i < dimensionCount; i++) 00150 { 00151 v[i] = point->mDescriptor[i]; 00152 } 00153 buffer->Write(v.GetData(), sizeof(Real64) * dimensionCount); 00154 } 00155 }
Here is the call graph for this function:
|