Skip to content

Commit acbdc9e

Browse files
committed
updates in object active state
1 parent 5ab0f3e commit acbdc9e

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

source/annotatorlib/include/AnnotatorLib/Commands/NewAnnotation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ANNOTATORLIB_API NewAnnotation : public Command {
2626
const shared_ptr<Class> newObjectClass,
2727
std::shared_ptr<Session> session, shared_ptr<Frame> frame,
2828
float x, float y, float width, float height,
29-
float confidence = 1.0);
29+
float confidence = 1.0, bool objectActive = true);
3030

3131
NewAnnotation(std::shared_ptr<Session> session, shared_ptr<Object> object_,
3232
shared_ptr<Frame> frame_, float x, float y, float width,
@@ -53,6 +53,7 @@ class ANNOTATORLIB_API NewAnnotation : public Command {
5353
const shared_ptr<Class> newObjectClass;
5454
shared_ptr<Annotation> annotation_;
5555
const bool createNewObject;
56+
bool objectActive = true;
5657
bool createdNewObject = false;
5758
};
5859
}

source/annotatorlib/source/Algo/InterpolateAnnotation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ shared_ptr<Annotation> InterpolateAnnotation::getInterpolation(
8383
}
8484

8585
} else if (object->getLastAnnotation() &&
86-
*frame > *object->getLastAnnotation()->getFrame()) {
86+
*frame > *object->getLastAnnotation()->getFrame() &&
87+
object->isActive()) {
8788
// copy the previous annotation to the requested frame
8889
return Annotation::make_shared(object->getLastAnnotation(), frame, true);
8990
}

source/annotatorlib/source/Commands/NewAnnotation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
AnnotatorLib::Commands::NewAnnotation::NewAnnotation(
88
const unsigned long newObjectId, const shared_ptr<Class> newObjectClass,
99
std::shared_ptr<Session> session, shared_ptr<Frame> frame, float x, float y,
10-
float width, float height, float confidence)
10+
float width, float height, float confidence, bool objectActive)
1111
: newObjectId(newObjectId),
1212
newObjectClass(newObjectClass),
1313
createNewObject(true) {
@@ -18,6 +18,7 @@ AnnotatorLib::Commands::NewAnnotation::NewAnnotation(
1818
this->width = width;
1919
this->height = height;
2020
this->confidence = confidence;
21+
this->objectActive = objectActive;
2122
}
2223

2324
AnnotatorLib::Commands::NewAnnotation::NewAnnotation(
@@ -46,6 +47,7 @@ bool AnnotatorLib::Commands::NewAnnotation::execute(
4647
bool success = session->addAnnotation(
4748
annotation_, true); // adds annotation and register to them
4849
if (createNewObject && success) createdNewObject = true;
50+
if (!objectActive) object->setActive(false);
4951
if (informSession) {
5052
informSession->updateAnnotation(this->annotation_);
5153
}

source/annotatorlib/source/Commands/UpdateAttribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ bool AnnotatorLib::Commands::UpdateAttribute::execute(
3737
bool AnnotatorLib::Commands::UpdateAttribute::undo(
3838
AnnotatorLib::Session *informSession) {
3939
// TODO
40-
return true;
40+
return true;
4141
}

source/annotatorlib/source/Storage/JSONLoader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ void JSONLoader::loadAnnotations(Poco::JSON::Object::Ptr json,
134134
}
135135
}
136136
session->addAnnotation(a);
137+
if (value->has("next") && value->get("next") == value->get("id")) {
138+
o->setActive(false);
139+
}
137140
}
138141
}
139142
}

source/storages/mongodb/MongoDBLoader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ void MongoDBLoader::loadAnnotations(Poco::MongoDB::Connection &connection,
6969
a->setPosition(x, y, width, height);
7070
session->addAnnotation(a);
7171
loadAnnotationAttributes(connection, a);
72+
try {
73+
if ((*it)->get<int>("next") == (*it)->get<int>("id"))
74+
o->setActive(false);
75+
} catch (...) {
76+
}
7277
}
7378
}
7479
if (response.cursorID() == 0) {

0 commit comments

Comments
 (0)