本文整理汇总了C++中osg::ref_ptr::frame方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::frame方法的具体用法?C++ ref_ptr::frame怎么用?C++ ref_ptr::frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::frame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderer
/*
The main rendering function.
*/
void renderer()
{
// Capture the image
IplImage *image = capture->captureImage();
// Check if we need to change image origin and is so, flip the image.
bool flip_image = (image->origin?true:false);
if (flip_image) {
cvFlip(image);
image->origin = !image->origin;
}
// Detect all the markers from the frame
markerDetector.Detect(image, &camera, false, false);
// Loop throught the list of detected markers
for (size_t i=0; i<markerDetector.markers->size(); i++) {
// Get the ID of the marker
int id = (*(markerDetector.markers))[i].GetId();
// Get the marker's pose (transformation matrix)
double temp_mat[16];
alvar::Pose p = (*(markerDetector.markers))[i].pose;
p.GetMatrixGL(temp_mat);
if( id == 5){ //Marker 5 is visible
//Switch the 5 on
modelSwitch->setChildValue(mtForMarkerFive, 1);
// Update the matrix transformation
mtForMarkerFive->setMatrix(osg::Matrix(temp_mat));
}
else if(id == 10){ //Marker 10 is visible
//Switch the 10 on
modelSwitch->setChildValue(mtForMarkerTen, 1);
// Update the matrix transformation
mtForMarkerTen->setMatrix(osg::Matrix(temp_mat));
}
}
// In case we flipped the image, it's time to flip it back
if (flip_image) {
cvFlip(image);
image->origin = !image->origin;
}
// "copy" the raw image data from IplImage to the Osg::Image
videoImage->setImage(image->width, image->height, 1, 4, GL_BGR, GL_UNSIGNED_BYTE, (unsigned char*)image->imageData, osg::Image::NO_DELETE);
if(videoImage.valid()){
// Set the latest frame to the view as an background texture
videoBG.SetBGImage(videoImage.get());
}
// Draw the frame
viewer->frame();
//Swiths all the models of until next frame
modelSwitch->setAllChildrenOff();
}
示例2: display
void display(void)
{
// update and render the scene graph
if (viewer.valid()) viewer->frame();
// Swap Buffers
glutSwapBuffers();
glutPostRedisplay();
}
示例3: Process
/*
Process each captured video frame.
*/
void Process()
{
reset = true;
while (true)
{
frame = capture->captureImage();
if (frame == 0)
continue; // TODO: For some reason CvCam gives NULL sometimes?
if(frame->origin==1)
{
cvFlip(frame);
frame->origin=0;
}
if (frame->nChannels == 1)
{
gray->imageData = frame->imageData;
cvCvtColor(frame, rgb, CV_BayerGB2RGB); // TODO: Now this assumes Bayer
}
else
{
rgb->imageData = frame->imageData;
cvCvtColor(frame, gray, CV_RGB2GRAY);
}
gray->origin = frame->origin;
if (reset)
{
reset = false;
}
alvar::Pose pose;
double error = GetMultiMarkerPose(frame, &cam, pose);
bool track_ok = (error>=0.0 && error<5.0);
if (track_ok)
{
// Draw cameras, points & features
double gl_mat[16];
pose.GetMatrixGL(gl_mat);
model_transform->setMatrix(osg::Matrix(gl_mat));
model_switch->setAllChildrenOn();
}
else
{
model_switch->setAllChildrenOff();
// std::cout << "\rTrack Failed ";
}
viewBG->DrawImage(rgb);
if (viewer->done())
break;
viewer->frame();
if (stop_running)
break;
}
}