Skip to content

Commit 38b3e6c

Browse files
committed
CloudViewer: fixed an iterator comparison error
1 parent 2953217 commit 38b3e6c

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

guilib/src/CloudViewer.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ void CloudViewer::removeText(const std::string & id)
844844
return;
845845
}
846846

847-
if(_texts.find(id) != _coordinates.end())
847+
if(_texts.find(id) != _texts.end())
848848
{
849849
_visualizer->removeText3D(id);
850850
_texts.erase(id);
@@ -959,15 +959,28 @@ void CloudViewer::getCameraPosition(
959959
{
960960
std::vector<pcl::visualization::Camera> cameras;
961961
_visualizer->getCameras(cameras);
962-
x = cameras.front().pos[0];
963-
y = cameras.front().pos[1];
964-
z = cameras.front().pos[2];
965-
focalX = cameras.front().focal[0];
966-
focalY = cameras.front().focal[1];
967-
focalZ = cameras.front().focal[2];
968-
upX = cameras.front().view[0];
969-
upY = cameras.front().view[1];
970-
upZ = cameras.front().view[2];
962+
if(cameras.size())
963+
{
964+
x = cameras.begin()->pos[0];
965+
y = cameras.begin()->pos[1];
966+
z = cameras.begin()->pos[2];
967+
focalX = cameras.begin()->focal[0];
968+
focalY = cameras.begin()->focal[1];
969+
focalZ = cameras.begin()->focal[2];
970+
upX = cameras.begin()->view[0];
971+
upY = cameras.begin()->view[1];
972+
upZ = cameras.begin()->view[2];
973+
}
974+
else
975+
{
976+
_visualizer->setCameraPosition(
977+
-1, 0, 0,
978+
0, 0, 0,
979+
0, 0, 1);
980+
x=-1.0f;
981+
y=z=focalX=focalY=focalZ=upX=upY=0;
982+
upZ=1.0f;
983+
}
971984
}
972985

973986
void CloudViewer::setCameraPosition(

0 commit comments

Comments
 (0)