static IplImage* load_image(S3ConnectionPtr s3conn, ImageMetadata *meta) { std::string key(meta->imagetable->prefix); key += "/" + meta->name; GetResponsePtr res = s3conn->get(CVDB::BUCKET, key); std::istream& ins = res->getInputStream(); IplImage *image = read_image(meta, ins); return image; }
bool get ( S3ConnectionPtr aS3, const std::string& aBucketName, const std::string& aKey ) { try { GetResponsePtr lGet = aS3->get(aBucketName, aKey); char buf[512]; std::istream& lIn = lGet->getInputStream(); while (lIn.good()) { lIn.read(buf, 512); std::cout.write(buf, lIn.gcount()); } } catch (GetException &e) { std::cerr << e.what() << std::endl; return false; } return true; }
int getobject(S3Connection* lS3Rest) { { try { GetResponsePtr lGet = lS3Rest->get("28msec_s3buckettest", "a/b/c"); std::istream& lInStream = lGet->getInputStream(); std::cout << "content-length: " << lGet->getContentLength() << std::endl; std::cout << "content-type: " << lGet->getContentType() << std::endl; std::cout << "ETag " << lGet->getETag() << std::endl; char lBuf[lGet->getContentLength()+1]; size_t lRead = lInStream.readsome(lBuf, lGet->getContentLength()); lBuf[lRead] = 0; std::cout.write (lBuf, lRead); std::cout << std::endl << "Object retrieved successfully" << std::endl; std::map<std::string, std::string> lMap = lGet->getMetaData(); for (std::map<std::string, std::string>::const_iterator lIter = lMap.begin(); lIter != lMap.end(); ++lIter) { std::cout << "Meta-data name: " << (*lIter).first << " value: " << (*lIter).second << std::endl; } } catch (GetException& e) { std::cerr << "Could get object" << std::endl; std::cerr << e.what() << std::endl; return 1; } } { try { lS3Rest->get("28msec_s3buckettest", "x"); return 1; } catch (GetException& e) { std::cerr << "Couldn't get object" << std::endl; std::cerr << e.what() << std::endl; } } return 0; }
static void load_image_eigen(S3ConnectionPtr s3conn, ImageMetadata *meta) { char buf[32]; std::string key(meta->imagetable->prefix); key += "/"; key += EIGEN_PREFIX; key += "/"; sprintf(buf, "%d.eigen", meta->id); key += buf; if (meta->features == NULL) { meta->features = new float[meta->imagetable->eigenspace->dimension]; } GetResponsePtr res = s3conn->get(CVDB::BUCKET, key); std::istream& ins = res->getInputStream(); ins.read((char*)(meta->features), sizeof(float)*meta->imagetable->eigenspace->dimension); }
static IplImage* load_staged_image(S3ConnectionPtr s3conn, const std::string& key) { GetResponsePtr res = s3conn->get(CVDB::BUCKET, key); std::istream& ins = res->getInputStream(); int fmt; ins >> fmt; assert(fmt == PS3M); int channels; ins >> channels; Dimensions dim; ins >> dim.width; ins >> dim.height; ins >> dim.depth; ins.ignore(); IplImage *image = cvCreateImage(cvSize(dim.width, dim.height), dim.depth, channels); ins.read(image->imageData, image->imageSize); return image; }