本文整理汇总了C++中Point2D::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2D::isValid方法的具体用法?C++ Point2D::isValid怎么用?C++ Point2D::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2D
的用法示例。
在下文中一共展示了Point2D::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTargets
// ######################################################################
void VisualTracker::setTargets(const Image<byte>& grey, const Point2D<int> loc)
{
if (!loc.isValid())
{
itsTracking = false;
return;
}
if (itsInitTracker)
initTracker(grey.getDims());
#ifdef HAVE_OPENCV
itsCurrentNumPoints = itsMaxNumPoints;
IplImage* currentImg = img2ipl(grey);
itsCurrentPoints[0].x = loc.i;
itsCurrentPoints[0].y = loc.j;
//cvFindCornerSubPix(currentImg, itsCurrentPoints, itsCurrentNumPoints,
// cvSize(itsInitTrackWindowSize.getVal(),itsInitTrackWindowSize.getVal()),
// cvSize(-1,-1),
// cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,
// 20,0.03));
cvReleaseImageHeader(¤tImg);
itsPreviousGreyImg = grey;
itsTrackFlags = 0;
IplImage *swap_temp;
CV_SWAP( itsPreviousPyramid, itsCurrentPyramid, swap_temp );
CvPoint2D32f* swap_points;
CV_SWAP( itsPreviousPoints, itsCurrentPoints, swap_points );
if (itsUseKalman)
{
itsKalman->state_post->data.fl[0] = loc.i;
itsKalman->state_post->data.fl[1] = loc.j;
}
#endif
itsTracking = true;
}
示例2: main
int main(const int argc, const char **argv)
{
MYLOGVERB = LOG_INFO;
mgr = new ModelManager("Test ObjRec");
nub::soft_ref<SimEventQueueConfigurator>
seqc(new SimEventQueueConfigurator(*mgr));
mgr->addSubComponent(seqc);
//our brain
nub::ref<StdBrain> brain(new StdBrain(*mgr));
mgr->addSubComponent(brain);
mgr->exportOptions(MC_RECURSE);
mgr->setOptionValString(&OPT_VisualCortexType, "IOC");
//mgr.setOptionValString(&OPT_VisualCortexType, "I");
//mgr->setOptionValString(&OPT_VisualCortexType, "GNO");
//mgr.setOptionValString(&OPT_VisualCortexType, "N");
//manager.setOptionValString(&OPT_UseOlderVersion, "false");
// set the FOA and fovea radii
mgr->setOptionValString(&OPT_SaliencyMapType, "Fast");
mgr->setOptionValString(&OPT_SMfastInputCoeff, "1");
mgr->setOptionValString(&OPT_WinnerTakeAllType, "Fast");
mgr->setOptionValString(&OPT_SimulationTimeStep, "0.2");
mgr->setModelParamVal("FOAradius", 50, MC_RECURSE);
mgr->setModelParamVal("FoveaRadius", 50, MC_RECURSE);
mgr->setOptionValString(&OPT_IORtype, "Disc");
if (mgr->parseCommandLine(
(const int)argc, (const char**)argv, "<Network file> <server ip>", 2, 2) == false)
return 1;
// catch signals and redirect them to terminate for clean exit:
signal(SIGHUP, terminateProc); signal(SIGINT, terminateProc);
signal(SIGQUIT, terminateProc); signal(SIGTERM, terminateProc);
signal(SIGALRM, terminateProc);
mgr->start();
ComplexChannel *cc =
&*dynCastWeak<ComplexChannel>(brain->getVC());
//Get a new descriptor vector
DescriptorVec descVec(*mgr, "Descriptor Vector", "DecscriptorVec", cc);
//Get new classifier
Bayes bayesNet(descVec.getFVSize(), 0);
//get command line options
const char *bayesNetFile = mgr->getExtraArg(0).c_str();
const char *server_ip = mgr->getExtraArg(1).c_str();
bool train = false;
int foveaRadius = mgr->getModelParamVal<int>("FoveaRadius", MC_RECURSE);
printf("Setting fovea to %i, train = %i\n", foveaRadius, train);
//load the network if testing
//if (!train)
bayesNet.load(bayesNetFile);
descVec.setFoveaSize(foveaRadius);
xwin = new XWinManaged(Dims(256,256),
-1, -1, "ILab Robot Head Demo");
server = nv2_label_server_create(9930,
server_ip,
9931);
nv2_label_server_set_verbosity(server,1); //allow warnings
int send_interval = 1;
while(!terminate)
{
double prob = 0, statSig = 0;
Point2D clickLoc = xwin->getLastMouseClick();
if (clickLoc.isValid())
train = !train;
struct nv2_image_patch p;
const enum nv2_image_patch_result res =
nv2_label_server_get_current_patch(server, &p);
std::string objName = "nomatch";
if (res == NV2_IMAGE_PATCH_END)
{
fprintf(stdout, "ok, quitting\n");
break;
}
else if (res == NV2_IMAGE_PATCH_NONE)
{
//.........这里部分代码省略.........
示例3: main
int main(const int argc, const char **argv)
{
MYLOGVERB = LOG_INFO;
mgr = new ModelManager("Test ObjRec");
if (mgr->parseCommandLine(
(const int)argc, (const char**)argv, "<vdb file> <server ip>", 2, 2) == false)
return 1;
mgr->start();
// catch signals and redirect them to terminate for clean exit:
signal(SIGHUP, terminateProc); signal(SIGINT, terminateProc);
signal(SIGQUIT, terminateProc); signal(SIGTERM, terminateProc);
signal(SIGALRM, terminateProc);
//get command line options
const char *vdbFile = mgr->getExtraArg(0).c_str();
const char *server_ip = mgr->getExtraArg(1).c_str();
bool train = false;
LINFO("Loading db from %s\n", vdbFile);
//vdb.loadFrom(std::string(vdbFile));
xwin = new XWinManaged(Dims(256,256),
-1, -1, "ILab Robot Head Demo");
labelServer =
nv2_label_server_create(9930,
server_ip,
9931);
nv2_label_server_set_verbosity(labelServer,1); //allow warnings
int send_interval = 1;
while(!terminate)
{
Point2D clickLoc = xwin->getLastMouseClick();
if (clickLoc.isValid())
train = !train;
struct nv2_image_patch p;
const enum nv2_image_patch_result res =
nv2_label_server_get_current_patch(labelServer, &p);
std::string objName;
if (res == NV2_IMAGE_PATCH_END)
{
fprintf(stdout, "ok, quitting\n");
break;
}
else if (res == NV2_IMAGE_PATCH_NONE)
{
usleep(10000);
continue;
}
else if (res == NV2_IMAGE_PATCH_VALID &&
p.type == NV2_PIXEL_TYPE_RGB24)
{
Image<PixRGB<byte> > img(p.width, p.height, NO_INIT);
memcpy(img.getArrayPtr(), p.data, p.width*p.height*3);
Image<PixRGB<byte> > inputImg = rescale(img, 256, 256);
std::string objName = matchObject(inputImg);
Image<PixRGB<byte> > disp(320, 240, ZEROS);
xwin->drawImage(inputImg);
if (objName == "nomatch")
{
if (train)
{
printf("Is this %s\n", objName.c_str());
std::string tmp;
std::getline(std::cin, tmp);
if (tmp == "exit") break;
if (tmp == "no")
{
printf("Can you tell me what this is?\n");
std::getline(std::cin, objName);
rutz::shared_ptr<VisualObject>
vo(new VisualObject(objName.c_str(), "NULL", inputImg,
Point2D(-1,-1),
std::vector<double>(),
std::vector< rutz::shared_ptr<Keypoint> >(),
USECOLOR));
vdb.addObject(vo);
vdb.saveTo(vdbFile);
}
}
} else {
printf("Object is %s\n", objName.c_str());
//.........这里部分代码省略.........
示例4: XWinManaged
// ######################################################################
void CenterSurroundHistogramSegmenter::drawCurrentCSbelief
(Point2D<int> pt, Rectangle grC, Rectangle grS)
{
uint width = itsImage.getWidth();
uint height = itsImage.getHeight();
if(itsWin.is_invalid())
itsWin.reset(new XWinManaged(Dims(2*width, height), 0, 0, "CSHse"));
else itsWin->setDims(Dims(2*width, height));
uint gwidth = width/GRID_SIZE;
uint gheight = height/GRID_SIZE;
// display the window
Image<PixRGB<byte> > disp(2*width, height, ZEROS);
inplacePaste(disp, itsImage, Point2D<int>(0,0));
if(pt.isValid())
{
drawCross(disp, pt, PixRGB<byte>(255,0,0), 10, 1);
}
if(grC.isValid())
{
drawRect(disp, grC*GRID_SIZE, PixRGB<byte>(255,0,0), 1);
drawRect(disp, grS*GRID_SIZE, PixRGB<byte>(0,255,0), 1);
}
float mVal = 32;
float bVal = 255 - mVal;
Image<byte> dImaR, dImaG, dImaB;
getComponents(itsImage, dImaR, dImaG, dImaB);
inplaceNormalize(dImaR, byte(0), byte(mVal));
inplaceNormalize(dImaG, byte(0), byte(mVal));
inplaceNormalize(dImaB, byte(0), byte(mVal));
Image<PixRGB<byte> > dIma = makeRGB(dImaR,dImaG,dImaB);
// Image<float> dImaCf = itsGridCenterBelief;
// inplaceNormalize(dImaCf, 0.0F, bVal);
// Image<byte> dImaCb(dImaCf);
// Image<PixRGB<byte> > dImaC = makeRGB(dImaCb,dImaCb,dImaCb);
// Image<float> dImaSf = itsGridSurroundBelief;
// inplaceNormalize(dImaSf, 0.0F, bVal);
// Image<byte> dImaSb(dImaSf);
// Image<PixRGB<byte> > dImaS = makeRGB(dImaSb,dImaSb,dImaSb);
// Image<PixRGB<byte> > tdImaC(dIma+zoomXY(dImaC,GRID_SIZE));
// Image<PixRGB<byte> > tdImaS(dIma+zoomXY(dImaS,GRID_SIZE));
// inplacePaste (disp, tdImaC, Point2D<int>(width,0));
// inplacePaste (disp, tdImaS, Point2D<int>(2*width,0));
Image<float> dImaCSf =
clampedDiff((itsGridCenterBelief - itsGridSurroundBelief),
Image<float>(gwidth,gheight,ZEROS));
inplaceNormalize(dImaCSf, 0.0F, bVal);
Image<byte> dImaCSb(dImaCSf);
Image<PixRGB<byte> > dImaCS = makeRGB(dImaCSb,dImaCSb,dImaCSb);
Image<PixRGB<byte> > tdImaCS(dIma+zoomXY(dImaCS,GRID_SIZE));
inplacePaste (disp, tdImaCS, Point2D<int>(width,0));
Point2D<int> noff (width,0);
drawCross(disp, pt+noff, PixRGB<byte>(255,0,0), 10, 1);
if(itsCSrectangle.isValid())
{
drawRect(disp, itsCSrectangle*GRID_SIZE, PixRGB<byte>(255,0,0), 1);
drawRect(disp, (itsCSrectangle*GRID_SIZE)+noff, PixRGB<byte>(255,0,0), 1);
}
itsWin->drawImage(disp,0,0);
Raster::waitForKey();
}