本文整理汇总了C++中readImage函数的典型用法代码示例。如果您正苦于以下问题:C++ readImage函数的具体用法?C++ readImage怎么用?C++ readImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GPU_PERF_TEST_1
GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_r_host.empty());
cv::gpu::StereoConstantSpaceBP csbp(128);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
csbp(img_l, img_r, dst);
declare.time(10.0);
TEST_CYCLE()
{
csbp(img_l, img_r, dst);
}
}
示例2: strdup
//Image readImage reads the same thing to every batch
//This call is here since this is the entry point called from allocate
//Movie overwrites this function to define how it wants to load into batches
int Movie::retrieveData(double timef, double dt)
{
int status = PV_SUCCESS;
bool init = false;
for(int b = 0; b < parent->getNBatch(); b++){
if(parent->icCommunicator()->commRank() == 0){
if(framePath[b]!= NULL) free(framePath[b]);
if(!initFlag){
framePath[b] = strdup(getNextFileName(startFrameIndex[b]+1, b));
init = true;
}
else{
framePath[b] = strdup(getNextFileName(skipFrameIndex[b], b));
}
std::cout << "Reading frame " << framePath[b] << " into batch " << b << " at time " << timef << "\n";
status = readImage(framePath[b], b, offsets[0], offsets[1], offsetAnchor);
}
else{
status = readImage(NULL, b, offsets[0], offsets[1], offsetAnchor);
}
if( status != PV_SUCCESS ) {
fprintf(stderr, "Movie %s: Error reading file \"%s\"\n", name, framePath[b]);
abort();
}
}
if(init){
initFlag = true;
}
return status;
}
示例3: PERF_TEST_P
PERF_TEST_P(DevInfo, StereoBeliefPropagation, testing::ValuesIn(devices()))
{
DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
ASSERT_FALSE(img_r_host.empty());
GpuMat img_l(img_l_host);
GpuMat img_r(img_r_host);
GpuMat dst;
StereoBeliefPropagation bp(128);
declare.time(10.0);
SIMPLE_TEST_CYCLE()
{
bp(img_l, img_r, dst);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
}
示例4: main
int main(int argc,char *argv){
FILE *fp;
char input[100];
scanf("%s",input);
char name[strlen(input)+1];
snprintf(name,sizeof(name),"%s",input);
fp=fopen(name,"rb");
if(fp==NULL){
printf("file not found\n");
return 0;
}
head *h=readHeader(fp);
pinfo info;
info.padding=0;
info.padding=calcPadding(h);
pi **a=readImage(h->width,h->height,h->bfoffset,fp,&info);
//The image is stored bottom to top and left to right
/* int swidth,sheight,ewidth,eheight;
printf("Enter the starting width and height: ");
scanf("%d %d",&swidth,&sheight);
printf("Enter the width and height to be cropped: ");
scanf("%d %d",&ewidth,&eheight);
crop(h,a,swidth,h->height-sheight,swidth+ewidth,h->height-sheight-eheight);
writeImage(fp,a,h,h->width,h->height,&info);
*/
// int swidth=598,sheight=375,ewidth=568,eheight=73;
// int swidth=620,sheight=372,ewidth=525,eheight=68;//scan
// int swidth=867,sheight=585,ewidth=775,eheight=75;//daa2,daa3
// int swidth=895,sheight=585,ewidth=775,eheight=75;//daa5
int swidth=895,sheight=585,ewidth=785,eheight=80;//daa6
a=crop(h,a,swidth,h->height-sheight,swidth+ewidth,h->height-sheight-eheight);
head *newH=changeHeader(h,ewidth,eheight);
// toJpeg("usn.jpeg",newH,a);
writeImage(a,newH,&info,"usn.bmp");
fp=fopen("usn.bmp","rb");
if(fp==NULL){
printf("file not found\n");
return 0;
}
h=readHeader(fp);
info.padding=calcPadding(h);
a=readImage(h->width,h->height,h->bfoffset,fp,&info);
slice(h,a,&info,10);
fclose(fp);
return 0;
}
示例5: SetUp
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
示例6: tr
void MainWindow::on_actionInsert_Image_triggered()
{
// imageBefore not loaded:
if (imageBefore.isNull())
{
QMessageBox::information(this, tr("ERROR"),tr("First you must open the image in which you want to hide another."));
return;
}
QMessageBox::information(this, tr("Choose file to hide..."),tr("REMEMBER: \n Chosen file must be much smaller than the image in which you want to hide it."));
QString imageToHidePath = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(),tr("Image (*.jpg *.bmp *.png)"));
if ( imageToHidePath != "" )
{
//load and show image to hide in After window:
readImage(imageToHidePath,imageAfter);
showImageAfter();
if (((imageBefore.byteCount()*3/4)/3)-2 > (imageAfter.byteCount()*3/4))
{
// hide imageAfter inside imageBefore:
Encoder encoder;
imageAfter = encoder.insertImage(imageBefore,imageAfter);
//and show it to the user
showImageAfter();
}
else
{
QMessageBox::information(this, tr("ERROR"),tr("File to encode is too big."));
}
}
}
示例7: invertImage
void invertImage(FILE *inf, FILE *outf) {
int i=0;
int width;
int height;
int max;
int w=0;
// Get width, height, and max from the file
rewind(inf);
eatLine(inf);
eatLine(inf);
fscanf(inf,"%d",&width);
fscanf(inf,"%d",&height);
fscanf(inf,"%d",&max);
// Initialize the array
float *darkValues;
// Read the values from the pgm file
darkValues = readImage(inf);
// Find the total number of 'i's we will have
int amtValues = width*height;
// Print the header to our pgm file
fprintf(outf,"P2\n");
fprintf(outf,"# CREATOR: BLAKE, THE MASTER OF C\n");
fprintf(outf,"%d %d\n",width,height);
fprintf(outf,"%d\n",max);
// For each pixel, invert the grey value
while (i < amtValues) {
fprintf(outf,"%d\n",((int)(max*(1.0-darkValues[i]))));
i++;
}
}
示例8: doc
// ---
void QGAMES::ObjectBuilder::preLoad ()
{
if (_alreadyLoaded)
return;
TiXmlDocument doc (_fileName.c_str ());
int e = doc.LoadFile ();
assert (e); // Is it a valid doc?
TiXmlElement* rootElement = doc.RootElement ();
assert (rootElement); // One element minimum...
// Reading all elements...
for (TiXmlElement* groupElement = rootElement -> FirstChildElement ();
groupElement != NULL; groupElement = groupElement -> NextSiblingElement ())
{
QGAMES::Object* obj = NULL;
if (strcmp (groupElement -> Value (), __QGAMES_IMAGEBLOCK__) == 0)
obj = readImage (groupElement); // An image...
if (strcmp (groupElement -> Value (), __QGAMES_BACKGROUNDBLOCK__) == 0)
obj = readBackground (groupElement); // A background...
if (strcmp (groupElement -> Value (), __QGAMES_POLYLINEBLOCK__) == 0)
obj = readGraphicalPolyline (groupElement); // A Polyline...
if (strcmp (groupElement -> Value (), __QGAMES_POLYGONBLOCK__) == 0)
obj = readGraphicalPolygon (groupElement); // A Polygon...
if (strcmp (groupElement -> Value (), __QGAMES_ELLIPSEBLOCK__) == 0)
obj = readEllipse (groupElement); // An ellipse...
if (strcmp (groupElement -> Value (), __QGAMES_COMPOSITEBLOCK__) == 0)
obj = readComposite (groupElement); // A composite made up of all of them...
assert (obj != NULL);
_objects.insert (std::map <int, QGAMES::Object*>::value_type (obj -> id (), obj));
}
_alreadyLoaded = true;
}
示例9: learnImage
int learnImage(const char * filename ,unsigned int numberOfHorizontalTiles,unsigned int numberOfVerticalTiles)
{
struct Image * inputImage = readImage(filename,guessFilenameTypeStupid(filename),0);
if (inputImage!=0)
{
unsigned int tileWidth =inputImage->width/numberOfHorizontalTiles;
unsigned int tileHeight=inputImage->height/numberOfVerticalTiles;
fprintf(stderr,"Sucessfully opened image ( %ux%u ) , each tile is %ux%u ..\n",inputImage->width,inputImage->height,tileWidth,tileHeight);
unsigned int x,y,i=0;
for (y=0; y<numberOfVerticalTiles; y++)
{
for (x=0; x<numberOfHorizontalTiles; x++)
{
struct Image * part = createImageBitBlt(inputImage,x*tileWidth , y*tileHeight , tileWidth, tileHeight);
if (part!=0)
{
char tileString[512]={0};
snprintf(tileString,512,"tile-%05d.jpg",i);
writeImageFile(part,JPG_CODEC,tileString);
destroyImage(part);
}
++i;
}
}
destroyImage(inputImage);
return 1;
}
return 0;
}
示例10: main
/**
* Main program
* @param argc Number of command line arguments, inlucing the program itself.
* @param argv Vector of command line arguments.
* @return EXIT_SUCCESS if program exits normally, EXIT_ERROR otherwise.
*/
int main(int argc, char** argv) {
if(argc < 2 || argc > 3) {
std::cout << "Usage: warper input_image [ouput_image]" << std::endl;
return EXIT_FAILURE;
}
readImage(argv[1]);
dumbProcess();
// Flip for openGL
openGLFlip();
// Init OpenGL
glutInit(&argc, argv);
openGLSetup(width, height);
if(argc == 3) {
outImage = argv[2];
canWrite = true;
}
// Start running display window
glutMainLoop();
return EXIT_SUCCESS;
}
示例11: main
int main(int argc, char *argv[])
{
char *iim, *idb, * oim;
ObjectDB newobjs, known;
Image im;
if (argc != 4) {
fprintf(stderr, "usage: %s <input labeled image> <input database> <output image>", argv[0]);
}
iim=argv[1];
idb=argv[2];
oim=argv[3];
readImage(&im, iim);
readDatabase(&known, idb); /* get the database of known objects */
makeODB(&newobjs, getColors(&im)); /* create the database for the input image */
getObjects(&im, &newobjs); /* fill the database for the input image */
filterObjects(&im, &newobjs, &known); /* find known objects in the database and throw away those unknown */
drawLines(&im, &newobjs); /* draw lines in the input image */
writeImage(&im, oim); /* write the output image */
free(newobjs.objs);
free(known.objs);
free(im.data);
return 0;
}
示例12: main
int main(int argc, char **argv) {
int i;
int window;
int threshold;
FILE *a;
double noise[] = {0.0,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50};
double *scores;
portImage *pa;
a = fopen(argv[1], "r");
sscanf(argv[2], "%d", &window);
pa = readImage(a);
scores = (double*)malloc( sizeof(double) * window * window );
if (!scores) {
fprintf(stderr, "Memory allocation failed.\n");
return 1;
}
for (i = 0; i < 11; i++) {
printf("%s,%2.2f,", argv[1], noise[i]);
calculateAverageDifference(pa, window, noise[i], scores);
for (threshold = 0; threshold < window*window; threshold++)
printf("%.3f,",scores[threshold]);
printf("\n");
}
free(scores);
freeImage(pa);
fclose(a);
return 0;
} // End Main
示例13: readImage
void OpenCVPicture::loadData(int scale, int flags) {
readImage(filename, mat, flags);
float s = scale * 1.0f / std::min(mat.rows, mat.cols);
transformImage(mat, backgroundColor, s, 0, 0, s);
xOffset = -mat.cols / 2;
yOffset = -mat.rows / 2;
}
示例14: main
int main(int argc, char *argv[])
{
if(argc < 2)
return -1;
// disable buffer on stdout to make 'printf' outputs
// immediately displayed in GUI-console
setbuf(stdout, NULL);
char * image = argv[1];
// initializations section
// processings section
cv::Mat block1_out1;
//readImage( "/Shared/TP_VTDVR/LIRIS-VISION/Applications/Starling/resource/guardians.jpg", &block1_out1);
readImage( image, &block1_out1);
cv::Mat block4_out1;
cv::cvtColor( *(&block1_out1), *(&block4_out1), CV_BGR2GRAY, 0);
showImage( "block2 (ESC to stop, SPACE to pause)", &block4_out1);
cv::waitKey(0);
// cleanings section
return 0;
}
示例15: GPU_PERF_TEST
GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE);
cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
declare.time(1.0);
TEST_CYCLE()
{
cv::gpu::labelComponents(mask, components);
}
}