Skip to content

Commit

Permalink
The tracker will now send a fake target (1,1,1,1) with a 0 confidence…
Browse files Browse the repository at this point in the history
… when not in the field of view.
  • Loading branch information
Ronan Chauvin authored and Ronan Chauvin committed Aug 2, 2014
1 parent a27cb75 commit f07234f
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 387 deletions.
19 changes: 9 additions & 10 deletions opentld/patches/diff.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- CMakeLists.txt 2012-10-10 15:54:29.465233428 -0400
+++ CMakeLists_.txt 2012-10-10 15:57:03.209233829 -0400
@@ -1,26 +1,3 @@
--- CMakeLists.txt 2014-08-02 06:41:53.000000000 -0400
+++ CMakeLists2.txt 2014-08-02 06:45:46.321882326 -0400
@@ -1,44 +1,9 @@
-# Open The CMake GUI
-# specify the source directory and the binary directory
-# press configure
Expand All @@ -24,10 +24,10 @@
-# directory
-# 5) build the project "PACKAGE" to create an NSIS-installer (NSIS is required)
-
-
project(OpenTLD)

@@ -28,17 +5,6 @@
cmake_minimum_required(VERSION 2.6)

find_package(OpenCV REQUIRED)

Expand All @@ -45,7 +45,7 @@
#------------------------------------------------------------------------------
#build type
if(NOT CMAKE_BUILD_TYPE)
@@ -47,33 +13,7 @@
@@ -47,32 +12,10 @@
FORCE)
endif(NOT CMAKE_BUILD_TYPE)

Expand All @@ -68,10 +68,9 @@
-set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
+add_definitions(-fPIC)

-#-------------------------------------------------------------------------------
-#add subdirectories
-add_subdirectory(src/3rdparty/cvblobs)
-
#-------------------------------------------------------------------------------
#add subdirectories

-if(NOT USE_SYSTEM_LIBS)
- add_subdirectory(src/3rdparty/libconfig)
-endif(NOT USE_SYSTEM_LIBS)
Expand Down
190 changes: 95 additions & 95 deletions tld_tracker/src/base_frame_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,124 +110,124 @@ void BaseFrameGraphicsView::image_received(const QImage & img)

void BaseFrameGraphicsView::tracked_objet_changed(const QRectF & rect)
{
//The tracker node sent a bounding box
if(rect.width() && rect.height())
{
if(!this->correct_bb)
{
this->correct_bb = true;
this->setCursor(Qt::ArrowCursor);
}
}
//The tracker node sent a bad bouding box
else
{
if(this->correct_bb)
{
this->correct_bb = false;
this->setCursor(Qt::CrossCursor);
}
//The tracker node sent a bounding box
if(rect.width() || rect.height())
{
if(!this->correct_bb)
{
this->correct_bb = true;
this->setCursor(Qt::ArrowCursor);
}
}
//The tracker node sent a bad bouding box
else
{
if(this->correct_bb)
{
this->correct_bb = false;
this->setCursor(Qt::CrossCursor);
}

this->m_item_rect->setRect(rect);
}

this->m_item_rect->setRect(rect);
}

void BaseFrameGraphicsView::resizeEvent(QResizeEvent * event)
{
fitInView(this->sceneRect(), Qt::KeepAspectRatio);
QGraphicsView::resizeEvent(event);
fitInView(this->sceneRect(), Qt::KeepAspectRatio);
QGraphicsView::resizeEvent(event);
}

void BaseFrameGraphicsView::mousePressEvent(QMouseEvent * event)
{
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);

qDebug() << "Press X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;

if(event->button() == Qt::LeftButton)
{
if(!correct_bb && !drag && !m_item_rect->isSelected())
{
point.setX((event->pos().x()-offset_x)/scale);
point.setY((event->pos().y()-offset_y)/scale);

drag = true;
}
}
QGraphicsView::mousePressEvent(event);
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);

qDebug() << "Press X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;

if(event->button() == Qt::LeftButton)
{
if(!correct_bb && !drag && !m_item_rect->isSelected())
{
point.setX((event->pos().x()-offset_x)/scale);
point.setY((event->pos().y()-offset_y)/scale);

drag = true;
}
}
QGraphicsView::mousePressEvent(event);
}

void BaseFrameGraphicsView::mouseMoveEvent(QMouseEvent * event)
{
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);

// qDebug() << "Move X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;
// qDebug() << "Move X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;

if(!correct_bb && drag && !m_item_rect->isSelected())
{
m_item_rect->setRect(point.x(), point.y(), ((event->pos().x()-offset_x)/scale) - point.x(), ((event->pos().y()-offset_y)/scale) - point.y());
this->update();
}
QGraphicsView::mouseMoveEvent(event);
if(!correct_bb && drag && !m_item_rect->isSelected())
{
m_item_rect->setRect(point.x(), point.y(), ((event->pos().x()-offset_x)/scale) - point.x(), ((event->pos().y()-offset_y)/scale) - point.y());
this->update();
}
QGraphicsView::mouseMoveEvent(event);
}

void BaseFrameGraphicsView::mouseReleaseEvent(QMouseEvent * event)
{
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);

qDebug() << "Release X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;

if(event->button() == Qt::LeftButton)
{
if(!correct_bb && drag && !m_item_rect->isSelected())
{
QRectF rect = m_item_rect->rect();
emit sig_bb_set(rect);
rect.normalized();
drag = false;
}
}
QGraphicsView::mouseReleaseEvent(event);
float scale, offset_x, offset_y;
this->computeScaleOffsets(scale, offset_x, offset_y);

qDebug() << "Release X : " << (event->pos().x()-offset_x)/scale << " Y : " << (event->pos().y()-offset_y)/scale;

if(event->button() == Qt::LeftButton)
{
if(!correct_bb && drag && !m_item_rect->isSelected())
{
QRectF rect = m_item_rect->rect();
emit sig_bb_set(rect);
rect.normalized();
drag = false;
}
}
QGraphicsView::mouseReleaseEvent(event);
}

/* Mathieu's function */
void BaseFrameGraphicsView::computeScaleOffsets(float & scale, float & offsetX, float & offsetY) const
{
scale = 1.0f;
offsetX = 0.0f;
offsetY = 0.0f;

float w = m_item_pixmap->pixmap().width();
float h = m_item_pixmap->pixmap().height();
float widthRatio = float(this->rect().width()) / w;
float heightRatio = float(this->rect().height()) / h;

//printf("w=%f, h=%f, wR=%f, hR=%f, sW=%d, sH=%d\n", w, h, widthRatio, heightRatio, this->rect().width(), this->rect().height());
if(widthRatio < heightRatio)
{
scale = widthRatio;
}
else
{
scale = heightRatio;
}

//printf("ratio=%f\n",ratio);

w *= scale;
h *= scale;

if(w < this->rect().width())
{
offsetX = (this->rect().width() - w)/2.0f;
}
if(h < this->rect().height())
{
offsetY = (this->rect().height() - h)/2.0f;
}
//printf("offsetX=%f, offsetY=%f\n",offsetX, offsetY);
scale = 1.0f;
offsetX = 0.0f;
offsetY = 0.0f;

float w = m_item_pixmap->pixmap().width();
float h = m_item_pixmap->pixmap().height();
float widthRatio = float(this->rect().width()) / w;
float heightRatio = float(this->rect().height()) / h;

//printf("w=%f, h=%f, wR=%f, hR=%f, sW=%d, sH=%d\n", w, h, widthRatio, heightRatio, this->rect().width(), this->rect().height());
if(widthRatio < heightRatio)
{
scale = widthRatio;
}
else
{
scale = heightRatio;
}

//printf("ratio=%f\n",ratio);

w *= scale;
h *= scale;

if(w < this->rect().width())
{
offsetX = (this->rect().width() - w)/2.0f;
}
if(h < this->rect().height())
{
offsetY = (this->rect().height() - h)/2.0f;
}
//printf("offsetX=%f, offsetY=%f\n",offsetX, offsetY);
}

Loading

0 comments on commit f07234f

Please sign in to comment.