CCachedImagePtr CImageManager::getCachedImage (int index) { xl::CScopeLock lock(this); assert(index >= 0 && index < (int)getImageCount()); CCachedImagePtr cachedImage = m_cachedImages[index]; lock.unlock(); return cachedImage; }
xl::tstring CImageManager::getCurrentFileName () { xl::CScopeLock lock(this); assert(m_currIndex >= 0 && m_currIndex < getImageCount()); CCachedImagePtr cachedImage = m_cachedImages[m_currIndex]; lock.unlock(); return cachedImage->getFileName(); }
RECT AEResource::getTexClipInTexel(INT imgOffset, INT imgCellCount, BYTE inverse) { if (imgOffset < 0 || imgOffset >= getImageCount()) { AENSGameControl::exitGame("Cannot get sprite texture: image offset out of range."); } LONG x1, x2, y1, y2; switch (rtype) { case RES_1x1: case RES_5x1: x1 = 0; x2 = cellW; y1 = cellH * (imgOffset); y2 = y1 + cellH; break; case RES_1x5: case RES_2x5: case RES_4x5: x1 = cellW * (imgOffset % 5); x2 = x1 + cellW * imgCellCount; y1 = cellH * (imgOffset / 5); y2 = y1 + cellH; break; case RES_1x10: x1 = cellW * (imgOffset % 10); x2 = x1 + cellW * imgCellCount; y1 = 0; y2 = cellH; break; case RES_2x10: x1 = cellW * (imgOffset % 10); x2 = x1 + cellW * imgCellCount; y1 = cellH * (imgOffset / 10); y2 = y1 + cellH; break; case RES_5x10: x1 = cellW * (imgOffset % 10); x2 = x1 + cellW * imgCellCount; y1 = cellH * (imgOffset / 10); y2 = y1 + cellH; break; default: // Error break; } switch (inverse) { case TEXCLIP_INVERSE_X: std::swap(x1, x2); break; case TEXCLIP_INVERSE_Y: std::swap(y1, y2); break; case TEXCLIP_INVERSE_BOTH: std::swap(x1, x2); std::swap(y1, y2); break; default: break; } return RECT{ x1, y1, x2, y2 }; }
ome::compat::array<dimension_size_type, 3> FormatWriter::getZCTCoords(dimension_size_type index) const { assertId(currentId, true); return ome::bioformats::getZCTCoords(getDimensionOrder(), getSizeZ(), getEffectiveSizeC(), getSizeT(), getImageCount(), index); }
dimension_size_type FormatWriter::getIndex(dimension_size_type z, dimension_size_type c, dimension_size_type t) const { assertId(currentId, true); return ome::bioformats::getIndex(getDimensionOrder(), getSizeZ(), getEffectiveSizeC(), getSizeT(), getImageCount(), z, c, t); }
void FormatWriter::setPlane(dimension_size_type plane) const { assertId(currentId, true); if (plane >= getImageCount()) { boost::format fmt("Invalid plane: %1%"); fmt % plane; throw std::logic_error(fmt.str()); } const dimension_size_type currentPlane = getPlane(); if (currentPlane != plane && (plane > 0 && currentPlane != plane - 1)) { boost::format fmt("Plane set out of order: %1% (currently %2%)"); fmt % plane % currentPlane; throw std::logic_error(fmt.str()); } this->plane = plane; }
void MinimalTIFFWriter::setId(const boost::filesystem::path& id) { FormatWriter::setId(id); std::string flags("w"); // Get expected size of pixel data. ome::compat::shared_ptr<const ::ome::xml::meta::MetadataRetrieve> mr(getMetadataRetrieve()); storage_size_type pixelSize = significantPixelSize(*mr); if (enableBigTIFF(bigTIFF, pixelSize, *currentId, logger)) flags += '8'; tiff = TIFF::open(id, flags); ifd = tiff->getCurrentDirectory(); setupIFD(); // Create IFD mapping from metadata. MetadataRetrieve::index_type imageCount = metadataRetrieve->getImageCount(); dimension_size_type currentIFD = 0U; for (MetadataRetrieve::index_type i = 0; i < imageCount; ++i) { dimension_size_type planeCount = getImageCount(); tiff::IFDRange range; range.filename = *currentId; range.begin = currentIFD; range.end = currentIFD + planeCount; seriesIFDRange.push_back(range); currentIFD += planeCount; } }
int generate(int num_samples) { msr::airlib::MultirotorRpcLibClient client; client.confirmConnection(); msr::airlib::ClockBase* clock = msr::airlib::ClockFactory::get(); RandomPointPoseGenerator pose_generator(static_cast<int>(clock->nowNanos())); std::fstream file_list(FileSystem::combine(storage_dir_, "files_list.txt"), std::ios::out | std::ios::in | std::ios_base::app); int sample = getImageCount(file_list); common_utils::ProsumerQueue<ImagesResult> results; std::thread result_process_thread(processImages, & results); try { while(sample < num_samples) { //const auto& collision_info = client.getCollisionInfo(); //if (collision_info.has_collided) { // pose_generator.next(); // client.simSetPose(pose_generator.position, pose_generator.orientation); // std::cout << "Collison at " << VectorMath::toString(collision_info.position) // << "Moving to next pose: " << VectorMath::toString(pose_generator.position) // << std::endl; // continue; //} ++sample; auto start_nanos = clock->nowNanos(); std::vector<ImageRequest> request = { ImageRequest(0, ImageType::Scene), ImageRequest(1, ImageType::Scene), ImageRequest(1, ImageType::DisparityNormalized, true) }; const std::vector<ImageResponse>& response = client.simGetImages(request); if (response.size() != 3) { std::cout << "Images were not recieved!" << std::endl; start_nanos = clock->nowNanos(); continue; } ImagesResult result; result.file_list = &file_list; result.response = response; result.sample = sample; result.render_time = clock->elapsedSince(start_nanos);; result.storage_dir_ = storage_dir_; result.position = pose_generator.position; result.orientation = pose_generator.orientation; results.push(result); pose_generator.next(); client.simSetPose(Pose(pose_generator.position, pose_generator.orientation), true); } } catch (rpc::timeout &t) { // will display a message like // rpc::timeout: Timeout of 50ms while calling RPC function 'sleep' std::cout << t.what() << std::endl; } results.setIsDone(true); result_process_thread.join(); return 0; }
AERect AEResource::getTexClip(INT imgOffset, INT imgCellCount, BYTE inverse) { if (imgOffset < 0 || imgOffset >= getImageCount()) { AENSGameControl::exitGame("Cannot get sprite texture: image offset out of range."); } FLOAT x1, x2, y1, y2; switch (rtype) { case RES_1x1: x1 = 0.0f; x2 = 1.0f; y1 = 0.0f; y2 = 1.0f; break; case RES_1x5: x1 = 0.2f * (imgOffset % 5); x2 = x1 + 0.2f * imgCellCount; y1 = 0.0f; y2 = 1.0f; break; case RES_5x1: x1 = 0.0f; x2 = 1.0f; y1 = 0.2f * (imgOffset); y2 = y1 + 0.2f; break; case RES_1x10: x1 = 0.1f * (imgOffset % 10); x2 = x1 + 0.1f * imgCellCount; y1 = 0.0f; y2 = 1.0f; break; case RES_2x5: x1 = 0.2f * (imgOffset % 5); x2 = x1 + 0.2f * imgCellCount; y1 = 0.5f * (imgOffset / 5); y2 = y1 + 0.5f; break; case RES_4x5: x1 = 0.2f * (imgOffset % 5); x2 = x1 + 0.2f * imgCellCount; y1 = 0.25f * (imgOffset / 5); y2 = y1 + 0.25f; break; case RES_2x10: x1 = 0.1f * (imgOffset % 10); x2 = x1 + 0.1f * imgCellCount; y1 = 0.5f * (imgOffset / 5); y2 = y1 + 0.5f; break; case RES_5x10: x1 = 0.1f * (imgOffset % 10); x2 = x1 + 0.1f * imgCellCount; y1 = 0.2f * (imgOffset / 10); y2 = y1 + 0.2f; break; default: // Error break; } switch (inverse) { case TEXCLIP_INVERSE_X: std::swap(x1, x2); break; case TEXCLIP_INVERSE_Y: std::swap(y1, y2); break; case TEXCLIP_INVERSE_BOTH: std::swap(x1, x2); std::swap(y1, y2); break; default: break; } return AERect(x1, y1, x2, y2); }