Definition at line 42 of file ImageArchiveRepositoryInMonet.h. References Impala::Util::Bin2Hex(), Impala::Persistency::RepositoryInMonetDB::GetConnection(), Impala::Persistency::ImageArchiveLocator::GetFrames(), Impala::Core::Array::ImageArchive::GetImageData(), Impala::Persistency::ImageArchiveLocator::GetName(), Impala::Persistency::ImageArchiveLocator::GetQuid(), ILOG_ERROR, ILOG_INFO, Impala::MakeString(), Impala::Core::Array::ImageArchive::NrImages(), Impala::Core::Array::ImageArchive::ReadImage(), RepMonet(), and Impala::Timer::SplitTime(). 00043 { 00044 if (!loc.GetFrames()) 00045 { 00046 ILOG_ERROR("Only implemented for frames"); 00047 return; 00048 } 00049 if (loc.GetName() != "images_jpg.raw") 00050 { 00051 ILOG_ERROR("Only implemented for jpg's of all frames"); 00052 return; 00053 } 00054 00055 Connection* conn = RepMonet().GetConnection(loc); 00056 Quid vidQuid = loc.GetQuid(); 00057 00058 conn->Query("delete from i_bulk_frame_image;", false, false); 00059 int totalSize = archive->NrImages(); 00060 int bulkSize = 4000; 00061 Timer timer; 00062 00063 for (int i=0 ; i<totalSize ; i+=bulkSize) 00064 { 00065 int left = totalSize - i; 00066 int nr = (left > bulkSize) ? bulkSize : left; 00067 String q = "copy " + MakeString(nr) + 00068 " records into i_bulk_frame_image from stdin" + 00069 " using delimiters ' ';\n"; 00070 for (int j=i ; j<i+nr ; j++) 00071 { 00072 Array2dVec3UInt8* im = archive->ReadImage(j); 00073 size_t dataSize = 0; 00074 UInt8* data = archive->GetImageData(j, dataSize); 00075 String hexData = Util::Bin2Hex(data, dataSize); 00076 delete data; 00077 String name = "frame" + MakeString(j); 00078 String width = MakeString(im->CW()); 00079 String height = MakeString(im->CH()); 00080 q += MakeString(vidQuid) + " " + MakeString(j) + " " + name + " " 00081 + hexData + " " + width + " " + height + " image/jpg \n"; 00082 delete im; 00083 } 00084 conn->Query(q, false, false); 00085 ILOG_INFO("Did bulk " << i << " at " << timer.SplitTime()); 00086 00087 conn->Query("insert into frame_image (fragment_id, image, width, \ 00088 height, mime_type) \ 00089 select fr.fragment_id, bf.image, bf.width, bf.height, \ 00090 bf.mime_type \ 00091 from i_bulk_frame_image bf, file f, fragment fr \ 00092 where bf.quid = f.quid and \ 00093 f.media_id = fr.media_id and \ 00094 fr.fragment_start = bf.fragment_start and \ 00095 fr.fragment_length = 1 and \ 00096 fr.keyframe = false \ 00097 order by bf.quid, bf.fragment_start;", false, false); 00098 ILOG_INFO("Did insert select at " << timer.SplitTime()); 00099 conn->Query("delete from i_bulk_frame_image;", false, false); 00100 } 00101 }
Here is the call graph for this function:
|