Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Applications/VpView/vpVidtkTrackIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,14 @@ bool vpVidtkTrackIO::WriteTracks(

double lat = 444.0;
double lon = 444.0;
vidtk::image_object_sptr obj;
vidtk::image_object* obj= nullptr;
vgl_box_2d<unsigned int> imageBox;
bool validObject = false;

if (orig_state && !orig_state->latitude_longitude(lat, lon))
{
if (orig_state->image_object(obj))
obj = orig_state->get_image_object();
if (obj != nullptr)
Comment on lines +641 to +642
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modernize:

Suggested change
obj = orig_state->get_image_object();
if (obj != nullptr)
if (auto* const obj = orig_state->get_image_object())

...and remove the prior declaration.

{
validObject = true;
imageBox = obj->get_bbox();
Expand Down Expand Up @@ -746,8 +747,7 @@ bool vpVidtkTrackIO::WriteTracks(
new_obj->set_bbox(newBox);
}

new_objs[0] = new_obj;
new_state->data_.set(vidtk::tracking_keys::img_objs, new_objs);
new_state->set_image_object(new_obj);

track->add_state(new_state);
}
Expand Down Expand Up @@ -936,7 +936,7 @@ void vpVidtkTrackIO::ReadTrack(
points.reserve(12);

bool skippedInterpolationPointSinceLastInsert = false;
std::vector<vidtk::image_object_sptr> objs;
vidtk::image_object_sptr obj;
for (const auto& trackState : trackHistory)
{
const auto frameNumber = trackState->time_.frame_number();
Expand Down Expand Up @@ -973,12 +973,13 @@ void vpVidtkTrackIO::ReadTrack(
timeStamp.SetTime(trackState->time_.time());
}

if (trackState->data_.get(vidtk::tracking_keys::img_objs, objs))
obj = trackState->get_image_object();
if (obj != nullptr)
Comment on lines +976 to +977
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, please modernize:

Suggested change
obj = trackState->get_image_object();
if (obj != nullptr)
if (auto const obj = trackState->get_image_object())

...and remove the prior declaration.

(Incidentally, I approve of getting rid of out parameters! Those are awful...)

{
double lat, lon;
if (!trackState->latitude_longitude(lat, lon))
{
const auto& world_loc = objs[0]->get_world_loc();
const auto& world_loc = obj->get_world_loc();
lon = world_loc[0];
lat = world_loc[1];
}
Expand All @@ -987,7 +988,7 @@ void vpVidtkTrackIO::ReadTrack(
bool trackPointAvailable = true;
double minY;
double maxY;
const auto& vglBBox = objs[0]->get_bbox();
const auto& vglBBox = obj->get_bbox();
double pt[4] = {0.0, 0.0, 0.0, 1.0};
vpFrame frameMetaData;
if (this->StorageMode == TSM_TransformedGeoCoords)
Expand All @@ -1005,7 +1006,7 @@ void vpVidtkTrackIO::ReadTrack(
}
else
{
const auto& image_loc = objs[0]->get_image_loc();
const auto& image_loc = obj->get_image_loc();
pt[0] = image_loc[0];
unsigned int imageMaxY = this->Reader.GetImageHeight() - 1;
if (this->StorageMode == TSM_InvertedImageCoords)
Expand Down
3 changes: 3 additions & 0 deletions Libraries/VtkVgCore/vtkVgTrack.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ void vtkVgTrack::InsertNextPoint(const vtkVgTimeStamp& timeStamp,
vtkPoints* fromShellPoints,
vtkIdType fromShellPtsStart)
{
vtkDebugMacro("insert next point: " << timeStamp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Suggested change
vtkDebugMacro("insert next point: " << timeStamp);


if (!this->Points)
{
vtkErrorMacro("Must set Points before inserting track points!");
Expand Down Expand Up @@ -709,6 +711,7 @@ void vtkVgTrack::SetPoint(const vtkVgTimeStamp& timeStamp,
vtkPoints* fromShellPts,
vtkIdType fromShellPtsStart)
{
vtkDebugMacro("set point: " << timeStamp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vtkDebugMacro("set point: " << timeStamp);

// if not closed and after the last point, just use InsertNextPoint()
if (!this->EndFrame.IsValid() &&
(this->Internal->PointIdMap.size() == 0 ||
Expand Down
11 changes: 5 additions & 6 deletions Libraries/VvVidtk/vvAdaptVidtk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
QList<vvTrackState> vvAdapt(const vidtk::track_state& vs)
{
QList<vvTrackState> stateList;
std::vector<vidtk::image_object_sptr> objs;
if (vs.data_.get(vidtk::tracking_keys::img_objs, objs))
vidtk::image_object* obj_sptr = vs.get_image_object();
if (obj_sptr != nullptr)
Comment on lines +21 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modernize:

Suggested change
vidtk::image_object* obj_sptr = vs.get_image_object();
if (obj_sptr != nullptr)
if (auto* const obj = vs.get_image_object())

Also, the variable name is wrong:

  • It isn't a smart pointer, so should not be named as if it were.
  • This code should use camelCase names, not names_with_underscores. (I'm aware some of this code already isn't following that, but let's not exacerbate the problem.)

{
for (size_t i = 0; i < objs.size(); ++i)
{
const vidtk::image_object& obj = *objs[i];
const vidtk::image_object& obj = *obj_sptr;

vvTrackState state;

Expand All @@ -38,8 +37,8 @@ QList<vvTrackState> vvAdapt(const vidtk::track_state& vs)
}

// Set image point and box
const auto& img_loc = objs[i]->get_image_loc();
const auto& bbox = objs[i]->get_bbox();
const auto& img_loc = obj_sptr->get_image_loc();
const auto& bbox = obj_sptr->get_bbox();
state.ImagePoint.X = img_loc[0];
state.ImagePoint.Y = img_loc[1];
state.ImageBox.TopLeft.X = bbox.min_x();
Expand Down