本文整理汇总了C++中readImage函数的典型用法代码示例。如果您正苦于以下问题:C++ readImage函数的具体用法?C++ readImage怎么用?C++ readImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readImage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:BRAINSia,项目名称:OpenCV_TruncatedSVN,代码行数:25,代码来源:perf_calib3d.cpp
示例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;
}
开发者ID:williamedwardhahn,项目名称:OpenPV,代码行数:34,代码来源:Movie.cpp
示例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);
}
开发者ID:malcolmreynolds,项目名称:OpenCV,代码行数:30,代码来源:perf_calib3d.cpp
示例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;
}
开发者ID:Siddhant085,项目名称:Pattern-Recognition,代码行数:58,代码来源:main.c
示例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());
}
开发者ID:dgiunchi,项目名称:OpenCV,代码行数:14,代码来源:test_calib3d.cpp
示例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."));
}
}
}
开发者ID:flp-mazur,项目名称:Project1,代码行数:30,代码来源:mainwindow.cpp
示例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++;
}
}
开发者ID:bdhall,项目名称:math442,代码行数:34,代码来源:pgmdo.c
示例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;
}
开发者ID:Commnets,项目名称:QGAMES,代码行数:35,代码来源:objectbuilder.cpp
示例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;
}
开发者ID:AmmarkoV,项目名称:RGBDAcquisition,代码行数:33,代码来源:learnImage.c
示例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;
}
开发者ID:joshua-hull,项目名称:School-Work,代码行数:33,代码来源:warp.cpp
示例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;
}
开发者ID:haywood,项目名称:Vision1,代码行数:28,代码来源:p4.c
示例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
开发者ID:jcchurch,项目名称:imgmanip,代码行数:32,代码来源:calcAD.c
示例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;
}
开发者ID:alxndrkalinin,项目名称:SparseConvNet,代码行数:7,代码来源:OpenCVTriangularPicture.cpp
示例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;
}
开发者ID:dtbinh,项目名称:TP_VTVRA,代码行数:28,代码来源:tp1.cpp
示例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);
}
}
开发者ID:Ye-Xiyong,项目名称:opencv,代码行数:26,代码来源:perf_labeling.cpp
示例16: readImage
int
ImageOverlap::setup()
{
int status = 0;
// Allocate host memoryF and read input image
std::string filePath = sampleCommon->getPath() + std::string(MAP_IMAGE);
std::string verifyfilePath = sampleCommon->getPath() + std::string(MAP_VERIFY_IMAGE);
status = readImage(filePath,verifyfilePath);
CHECK_ERROR(status, SDK_SUCCESS, "Read Map Image failed");
// create and initialize timers
int timer = sampleCommon->createTimer();
sampleCommon->resetTimer(timer);
sampleCommon->startTimer(timer);
status = setupCL();
if(status != SDK_SUCCESS)
return status;
sampleCommon->stopTimer(timer);
// Compute setup time
setupTime = (double)(sampleCommon->readTimer(timer));
return SDK_SUCCESS;
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:25,代码来源:ImageOverlap.cpp
示例17: test_by_pict
virtual void test_by_pict()
{
Mat frame1 = readImage("optflow/RubberWhale1.png", IMREAD_GRAYSCALE);
UMat usrc;
frame1.copyTo(usrc);
int histSize = randomInt(3, 29);
float hue_range[] = { 0, 180 };
const float* ranges1 = { hue_range };
Mat hist1;
//compute histogram
calcHist(&frame1, 1, 0, Mat(), hist1, 1, &histSize, &ranges1, true, false);
normalize(hist1, hist1, 0, 255, NORM_MINMAX, -1, Mat());
Mat dst1;
UMat udst1, src, uhist1;
hist1.copyTo(uhist1);
std::vector<UMat> uims;
uims.push_back(usrc);
std::vector<float> urngs;
urngs.push_back(0);
urngs.push_back(180);
std::vector<int> chs;
chs.push_back(0);
OCL_OFF(calcBackProject(&frame1, 1, 0, hist1, dst1, &ranges1, 1, true));
OCL_ON(calcBackProject(uims, chs, uhist1, udst1, urngs, 1.0));
EXPECT_MAT_NEAR(dst1, udst1, 0.0);
}
开发者ID:HanaLeeHn,项目名称:opencv,代码行数:30,代码来源:test_histogram.cpp
示例18: main
int main(int argc, char *argv[])
{
char *ifname, *odname, *ofname;
ObjectDB odb;
Image im;
if (argc < 4) {
fprintf(stderr, "usage: %s <input labeled image> <output database> <output image>", argv[0]);
return 1;
}
ifname=argv[1];
odname=argv[2];
ofname=argv[3];
readImage(&im, ifname);
makeODB(&odb, getColors(&im));
getObjects(&im, &odb);
writeDatabase(&odb, odname);
drawLines(&im, &odb);
writeImage(&im, ofname);
free(odb.objs);
free(im.data);
return 0;
}
开发者ID:haywood,项目名称:Vision1,代码行数:27,代码来源:p3.c
示例19: request
ImageLoader::Status ImageLoader::get(QImage &image) const
{
if (!ok()) return NETWORK_ERROR;
QByteArray request("[email protected]"), response;
request.append(number(mId), sizeof(mId));
if (!doRequest(request, response))
return NETWORK_ERROR;
const int bytesSize = 3 * sizeImage.height * sizeImage.width;
const int gotBytesSize = response.size();
if (gotBytesSize == bytesSize)
{
qDebug() << "got image";
image = readImage(response).copy();
return SUCCESS;
}
else if (gotBytesSize == 4 && response == "->[email protected]")
{
qDebug() << "done";
return DONE;
}
return NETWORK_ERROR;
}
开发者ID:geeknik96,项目名称:SegNetPrepar,代码行数:25,代码来源:ImageLoader.cpp
示例20: readImage
void fileManager::readFullTract( const std::string fullTractFilename, compactTract* tractPointer ) const
{
compactTract& tractogram = *tractPointer;
std::vector<std::vector<std::vector<float> > > fullTractMatrix;
ValueType fulltractValueType = readImage(fullTractFilename,&fullTractMatrix);
if ( fulltractValueType == VTError )
{
throw std::runtime_error( "ERROR @ fileManager::readFullTract(): Failed to read full tract image" );
}
if ( fulltractValueType != VTFloat32 && fulltractValueType != VTUINT8 )
{
throw std::runtime_error("ERROR @ fileManager::readFullTract(): tract representation type not recognized (neither Float32 nor UINT8)");
}
full2compact( fullTractMatrix, &(tractogram.m_tract) );
tractogram.m_inLogUnits = m_logFlag;
tractogram.m_norm = 0;
tractogram.m_normReady = false;
tractogram.m_thresholded = m_thresFlag;
if ( fulltractValueType == VTUINT8 )
{
for( int i = 0; i < tractogram.m_tract.size(); ++i )
{
tractogram.m_tract[i] = tractogram.m_tract[i]/255.;
}
}
return;
}// end fileManager::readFullTract() -----------------------------------------------------------------
开发者ID:dmordom,项目名称:hClustering,代码行数:30,代码来源:fileManager.cpp
注:本文中的readImage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论