This commit is contained in:
Olexa Bilaniuk 2014-11-22 12:28:19 -05:00
commit 38e3f2c7f5
10 changed files with 125 additions and 11 deletions

View File

@ -38,6 +38,11 @@ if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
if(POLICY CMP0026)
# silence cmake 3.0+ warnings about reading LOCATION attribute
cmake_policy(SET CMP0026 OLD)
endif()
# must go before the project command
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if(DEFINED CMAKE_BUILD_TYPE)

View File

@ -13,7 +13,7 @@ Explanation
Most of you will have played the jigsaw puzzle games. You get a lot of small pieces of a images, where you need to assemble them correctly to form a big real image. **The question is, how you do it?** What about the projecting the same theory to a computer program so that computer can play jigsaw puzzles? If the computer can play jigsaw puzzles, why can't we give a lot of real-life images of a good natural scenery to computer and tell it to stitch all those images to a big single image? If the computer can stitch several natural images to one, what about giving a lot of pictures of a building or any structure and tell computer to create a 3D model out of it?
Well, the questions and imaginations continue. But it all depends on the most basic question? How do you play jigsaw puzzles? How do you arrange lots of scrambled image pieces into a big single image? How can you stitch a lot of natural images to a single image?
Well, the questions and imaginations continue. But it all depends on the most basic question: How do you play jigsaw puzzles? How do you arrange lots of scrambled image pieces into a big single image? How can you stitch a lot of natural images to a single image?
The answer is, we are looking for specific patterns or specific features which are unique, which can be easily tracked, which can be easily compared. If we go for a definition of such a feature, we may find it difficult to express it in words, but we know what are they. If some one asks you to point out one good feature which can be compared across several images, you can point out one. That is why, even small children can simply play these games. We search for these features in an image, we find them, we find the same features in other images, we align them. That's it. (In jigsaw puzzle, we look more into continuity of different images). All these abilities are present in us inherently.

View File

@ -136,6 +136,8 @@ CV_EXPORTS_W void moveWindow(const String& winname, int x, int y);
CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title);
CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
//! assigns callback for mouse events

View File

@ -379,7 +379,8 @@ CV_IMPL void cvUpdateWindow(const char*)
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize,color,weight, style);
return *(cv::QtFont*)(&f);
void* pf = &f; // to suppress strict-aliasing
return *(cv::QtFont*)pf;
}
void cv::addText( const Mat& img, const String& text, Point org, const QtFont& font)
@ -490,6 +491,12 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
// version with a more capable one without a need to recompile dependent
// applications or libraries.
void cv::setWindowTitle(const String&, const String&)
{
CV_Error(Error::StsNotImplemented, "The function is not implemented. "
"Rebuild the library with Windows, GTK+ 2.x or Carbon support. "
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script");
}
#define CV_NO_GUI_ERROR(funcname) \
cvError( CV_StsError, funcname, \

View File

@ -181,6 +181,18 @@ void cvSetPropWindow_QT(const char* name,double prop_value)
Q_ARG(double, prop_value));
}
void cv::setWindowTitle(const String& winname, const String& title)
{
if (!guiMainThread)
CV_Error(Error::StsNullPtr, "NULL guiReceiver (please create a window)");
QMetaObject::invokeMethod(guiMainThread,
"setWindowTitle",
autoBlockingConnection(),
Q_ARG(QString, QString(winname.c_str())),
Q_ARG(QString, QString(title.c_str())));
}
void cvSetModeWindow_QT(const char* name, double prop_value)
{
@ -371,7 +383,7 @@ static CvWindow* icvFindWindowByName(QString name)
if (temp->type == type_CvWindow)
{
CvWindow* w = (CvWindow*) temp;
if (w->windowTitle() == name)
if (w->objectName() == name)
{
window = w;
break;
@ -527,7 +539,7 @@ CV_IMPL const char* cvGetWindowName(void* window_handle)
if( !window_handle )
CV_Error( CV_StsNullPtr, "NULL window handler" );
return ((CvWindow*)window_handle)->windowTitle().toLatin1().data();
return ((CvWindow*)window_handle)->objectName().toLatin1().data();
}
@ -871,6 +883,22 @@ void GuiReceiver::setPropWindow(QString name, double arg2)
w->setPropWindow(flags);
}
void GuiReceiver::setWindowTitle(QString name, QString title)
{
QPointer<CvWindow> w = icvFindWindowByName(name);
if (!w)
{
cvNamedWindow(name.toLatin1().data());
w = icvFindWindowByName(name);
}
if (!w)
return;
w->setWindowTitle(title);
}
double GuiReceiver::isFullScreen(QString name)
{
@ -1494,7 +1522,7 @@ void CvWinProperties::showEvent(QShowEvent* evnt)
//no value pos was saved so we let Qt move the window in the middle of its parent (event ignored).
//then hide will save the last position and thus, we want to retreive it (event accepted).
QPoint mypos(-1, -1);
QSettings settings("OpenCV2", windowTitle());
QSettings settings("OpenCV2", objectName());
mypos = settings.value("pos", mypos).toPoint();
if (mypos.x() >= 0)
@ -1511,7 +1539,7 @@ void CvWinProperties::showEvent(QShowEvent* evnt)
void CvWinProperties::hideEvent(QHideEvent* evnt)
{
QSettings settings("OpenCV2", windowTitle());
QSettings settings("OpenCV2", objectName());
settings.setValue("pos", pos()); //there is an offset of 6 pixels (so the window's position is wrong -- why ?)
evnt->accept();
}
@ -1520,7 +1548,7 @@ void CvWinProperties::hideEvent(QHideEvent* evnt)
CvWinProperties::~CvWinProperties()
{
//clear the setting pos
QSettings settings("OpenCV2", windowTitle());
QSettings settings("OpenCV2", objectName());
settings.remove("pos");
}
@ -1540,9 +1568,9 @@ CvWindow::CvWindow(QString name, int arg2)
//setAttribute(Qt::WA_DeleteOnClose); //in other case, does not release memory
setContentsMargins(0, 0, 0, 0);
setWindowTitle(name);
setObjectName(name);
setObjectName(name);
setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not received without the explicit focus
setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not received without the explicit focus
resize(400, 300);
setMinimumSize(1, 1);
@ -1702,7 +1730,6 @@ void CvWindow::setPropWindow(int flags)
}
}
void CvWindow::toggleFullScreen(int flags)
{
if (isFullScreen() && flags == CV_WINDOW_NORMAL)

View File

@ -132,6 +132,7 @@ public slots:
double isFullScreen(QString name);
double getPropWindow(QString name);
void setPropWindow(QString name, double flags );
void setWindowTitle(QString name, QString title);
double getRatioWindow(QString name);
void setRatioWindow(QString name, double arg2 );
void saveWindowParameters(QString name);

View File

@ -833,6 +833,23 @@ void cvSetModeWindow_CARBON( const char* name, double prop_value)//Yannick Verdi
__END__;
}
void cv::setWindowTitle(const String& winname, const String& title)
{
CvWindow* window = icvFindWindowByName(winname.c_str());
if (!window)
{
namedWindow(winname);
window = icvFindWindowByName(winname.c_str());
}
if (!window)
CV_Error(Error::StsNullPtr, "NULL window");
if (noErr != SetWindowTitleWithCFString(window->window, CFStringCreateWithCString(NULL, title.c_str(), kCFStringEncodingASCII)))
CV_Error_(Error::StsError, ("Failed to set \"%s\" window title to \"%s\"", winname.c_str(), title.c_str()));
}
CV_IMPL int cvNamedWindow( const char* name, int flags )
{
int result = 0;

View File

@ -150,7 +150,7 @@ CV_IMPL int cvInitSystem( int , char** )
#define NSAppKitVersionNumber10_5 949
#endif
if( floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5 )
[application setActivationPolicy:0/*NSApplicationActivationPolicyRegular*/];
[application setActivationPolicy:NSApplicationActivationPolicyRegular];
#endif
//[application finishLaunching];
//atexit(icvCocoaCleanup);
@ -603,6 +603,27 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
__END__;
}
void cv::setWindowTitle(const String& winname, const String& title)
{
CVWindow *window = cvGetWindow(winname.c_str());
if (window == NULL)
{
namedWindow(winname);
window = cvGetWindow(winname.c_str());
}
if (window == NULL)
CV_Error(Error::StsNullPtr, "NULL window");
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
NSString *windowTitle = [NSString stringWithFormat:@"%s", title.c_str()];
[window setTitle:windowTitle];
[localpool drain];
}
@implementation CVWindow
@synthesize mouseCallback;

View File

@ -732,6 +732,23 @@ void cvSetModeWindow_GTK( const char* name, double prop_value)//Yannick Verdie
__END__;
}
void cv::setWindowTitle(const String& winname, const String& title)
{
CvWindow* window = icvFindWindowByName(winname.c_str());
if (!window)
{
namedWindow(winname);
window = icvFindWindowByName(winname.c_str());
}
if (!window)
CV_Error(Error::StsNullPtr, "NULL window");
CV_LOCK_MUTEX();
gtk_window_set_title(GTK_WINDOW(window->frame), title.c_str());
CV_UNLOCK_MUTEX();
}
double cvGetPropWindowAutoSize_GTK(const char* name)
{

View File

@ -483,6 +483,23 @@ void cvSetModeWindow_W32( const char* name, double prop_value)//Yannick Verdie
__END__;
}
void cv::setWindowTitle(const String& winname, const String& title)
{
CvWindow* window = icvFindWindowByName(winname.c_str());
if (!window)
{
namedWindow(winname);
window = icvFindWindowByName(winname.c_str());
}
if (!window)
CV_Error(Error::StsNullPtr, "NULL window");
if (!SetWindowText(window->frame, title.c_str()))
CV_Error_(Error::StsError, ("Failed to set \"%s\" window title to \"%s\"", winname.c_str(), title.c_str()));
}
double cvGetPropWindowAutoSize_W32(const char* name)
{
double result = -1;