Moved from SourceForge to GitHub
This commit is contained in:
commit
ecd8d2a600
|
@ -0,0 +1,50 @@
|
|||
#include "about.h"
|
||||
#include "ui_about.h"
|
||||
#include "rlgpl.h"
|
||||
#include "rocvl.h"
|
||||
#include <QShortcut>
|
||||
|
||||
About::About(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::About)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QShortcut *shortcut = new QShortcut(QKeySequence("Esc"), this);
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(justClose()));
|
||||
|
||||
/*QPixmap image;
|
||||
QImage *imageObject;
|
||||
QGraphicsScene *scene;
|
||||
QString imagePath = "smallicon.gif";
|
||||
|
||||
imageObject = new QImage();
|
||||
imageObject->load(imagePath);
|
||||
|
||||
image = QPixmap::fromImage(*imageObject);
|
||||
|
||||
scene = new QGraphicsScene(this);
|
||||
scene->addPixmap(image);
|
||||
scene->setSceneRect(image.rect());
|
||||
ui->logo->setScene(scene);*/
|
||||
}
|
||||
|
||||
About::~About()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void About::readLicLGPL()
|
||||
{
|
||||
rlgpl fsf;
|
||||
fsf.setModal(false);
|
||||
fsf.exec();
|
||||
}
|
||||
|
||||
void About::readLicOCV()
|
||||
{
|
||||
rocvl bsd;
|
||||
bsd.setModal(false);
|
||||
bsd.exec();
|
||||
}
|
||||
|
||||
void About::justClose() {window()->close();}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef ABOUT_H
|
||||
#define ABOUT_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class About;
|
||||
}
|
||||
|
||||
class About : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit About(QWidget *parent = 0);
|
||||
~About();
|
||||
|
||||
public slots:
|
||||
void justClose();
|
||||
void readLicOCV();
|
||||
void readLicLGPL();
|
||||
|
||||
private:
|
||||
Ui::About *ui;
|
||||
};
|
||||
|
||||
#endif // ABOUT_H
|
|
@ -0,0 +1,347 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QDialog" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>330</width>
|
||||
<height>323</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About webCAMotion</string>
|
||||
</property>
|
||||
<property name="windowOpacity">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Overview</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Droid Sans</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>webCAMotion</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Graphical User Inerface - BETA 2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>2015</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Authors</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>These are the ones who made this thing real:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Adler O. S. Neves</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>License</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>This program is under GNU LGPL v3, uses Qt as "GUI-builder" (has a LGPL v3 compatible license), and a differently-licensed library to work properly (OpenCV), and if you agree with both licenses you can use this software.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>GNU LGPL:
|
||||
http://www.gnu.org/licenses/lgpl</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Qt license page:
|
||||
http://www.qt.io/licensing/</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>OpenCV license:
|
||||
http://opencv.org/license.html</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>LGPL v3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>OpenCV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>178</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>About</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>317</x>
|
||||
<y>308</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>162</x>
|
||||
<y>154</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>About</receiver>
|
||||
<slot>readLicLGPL()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>141</x>
|
||||
<y>250</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>134</x>
|
||||
<y>280</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton_3</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>About</receiver>
|
||||
<slot>readLicOCV()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>288</x>
|
||||
<y>261</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>283</x>
|
||||
<y>280</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>readLicLGPL()</slot>
|
||||
<slot>readLicOCV()</slot>
|
||||
</slots>
|
||||
</ui>
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
/home/adler/Documentos/webCAMotion/wdir/CPP/GUI/core/bin/Debug/core.o: \
|
||||
/home/adler/Documentos/webCAMotion/wdir/CPP/GUI/core/core.cpp
|
Binary file not shown.
|
@ -0,0 +1,208 @@
|
|||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
int GVAR1 = 0;
|
||||
|
||||
#include "core.h"
|
||||
#include "core.os.cpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
u_int8_t theCoolPart(int camnum, int smoothNumberFrames, int workingMethod, int inputoffset, int dtrig,
|
||||
int distanceAwayDisplay, int baseToEdgeDistance, int clickingDisabled,
|
||||
int colorBase, int colorEdge, int colorClicker, int screensize)
|
||||
{
|
||||
screenControl scrctrl = initScreenControl();
|
||||
coordinate mainScreenSize = ScrSize(scrctrl);
|
||||
int scrx = mainScreenSize.x;
|
||||
int scry = mainScreenSize.y;
|
||||
if (smoothNumberFrames<1){smoothNumberFrames=1;}; //avoiding crashes
|
||||
VideoCapture cap(camnum);
|
||||
if(!cap.isOpened()){endScreenControl(scrctrl);return -1;};
|
||||
char windowname[256]="webCAMotion - press ESC or click in the window to exit";
|
||||
namedWindow(windowname, WINDOW_AUTOSIZE);
|
||||
setMouseCallback(windowname, clickedInImage, NULL);
|
||||
Mat captured;
|
||||
Mat frame;
|
||||
Mat frameCP;
|
||||
Mat chGRAY;
|
||||
Mat frameS[3]; //I dont expect a 4-channel cammera
|
||||
coordinate coords[4]; //I dont expect a 4-channel cammera - 4th index is for mouse
|
||||
coordinate smoothedcoords[4]; //I dont expect a 4-channel cammera - 4th index is for mouse
|
||||
coordinate coordhistory[4][smoothNumberFrames+1]; //I dont expect a 4-channel cammera - 4th index is for mouse
|
||||
int dist[3];
|
||||
bool bdist[3];
|
||||
int mx;
|
||||
int my;
|
||||
int coordhistoryptr=0;
|
||||
int cn;
|
||||
int lin;
|
||||
int col;
|
||||
int clickcond;
|
||||
int clickcode;
|
||||
int k=0; //general purpose
|
||||
cap >> captured; //this frame is just for getting metadata
|
||||
while (captured.data == NULL && k<30){
|
||||
waitKey(5);
|
||||
cap >> captured;
|
||||
k++;
|
||||
}
|
||||
if(k==30){
|
||||
endScreenControl(scrctrl);
|
||||
return 7;
|
||||
}
|
||||
imshow(windowname, captured);
|
||||
lin=captured.rows;
|
||||
col=captured.cols;
|
||||
cn =captured.channels();
|
||||
if (cn!=3) {endScreenControl(scrctrl);return 3;};
|
||||
for(;;)
|
||||
{
|
||||
k=0;
|
||||
cap >> captured;
|
||||
while (captured.data == NULL && k<30){
|
||||
waitKey(5);
|
||||
cap >> captured;
|
||||
k++;
|
||||
}
|
||||
if(k==30){
|
||||
endScreenControl(scrctrl);
|
||||
return 7;
|
||||
}
|
||||
flip(captured,captured,1);
|
||||
cvtColor(captured,chGRAY,CV_BGR2GRAY);
|
||||
split(captured,frameS);
|
||||
merge(frameS,cn,frameCP);
|
||||
for (k=(cn-1);k>=0;k--)
|
||||
{
|
||||
subtract(frameS[k],chGRAY,frameS[k]);
|
||||
};
|
||||
merge(frameS,cn,frame);
|
||||
for (k=(cn-1);k>=0;k--)
|
||||
{
|
||||
coords[k]=bestIlluminati(frame,lin,col,k);
|
||||
};
|
||||
//SMOOTHING MOVEMENTS
|
||||
coordhistoryptr=((coordhistoryptr)%(smoothNumberFrames+1));
|
||||
for (k=0;k<cn;k++)
|
||||
{
|
||||
coordhistory[k][coordhistoryptr]=coords[k];
|
||||
};
|
||||
for (k=0;k<cn;k++)
|
||||
{
|
||||
smoothedcoords[k]=smootherPoints(coordhistory[k],coordhistoryptr,smoothNumberFrames);
|
||||
};
|
||||
//printf("%03dx%03d;%d==(%03d,%03d),(%03d,%03d),(%03d,%03d)\n",col,lin,cn,smoothedcoords[0].x,smoothedcoords[0].y,smoothedcoords[1].x,smoothedcoords[1].y,smoothedcoords[2].x,smoothedcoords[2].y);
|
||||
//printf("%03dx%03d;%d==(%03d,%03d),(%03d,%03d),(%03d,%03d)\n",col,lin,cn,coords[0].x,coords[0].y,coords[1].x,coords[1].y,coords[2].x,coords[2].y);
|
||||
//MAKING SELECTION VISIBLE
|
||||
/*for (k=0;k<cn;k++)
|
||||
{
|
||||
makeSelectionVisible(frameCP,k,cn,lin,col,smoothedcoords[k]);
|
||||
};*/
|
||||
for (k=(cn-1);k>=0;k--)
|
||||
{
|
||||
makeSelectionVisible(frameCP,k,cn,lin,col,coords[k]);
|
||||
};
|
||||
//SHOWING TO USER
|
||||
imshow(windowname, frameCP);
|
||||
if((waitKey(15) >= 0) || GVAR1) break;
|
||||
|
||||
///////////////////////////////////////
|
||||
//MOUSE EVENTS - PLANNING
|
||||
if (workingMethod==0)
|
||||
{
|
||||
mx=coords[2].x;
|
||||
my=coords[2].y;
|
||||
}
|
||||
else if (workingMethod==1)
|
||||
{
|
||||
mx=coords[1].x;
|
||||
my=coords[1].y;
|
||||
}
|
||||
else if (workingMethod==2)
|
||||
{
|
||||
mx=coords[0].x;
|
||||
my=coords[0].y;
|
||||
}
|
||||
else if (workingMethod==3)
|
||||
{
|
||||
mx=coords[1].x;
|
||||
my=coords[1].y;
|
||||
}
|
||||
else if (workingMethod==4)
|
||||
{
|
||||
coordhistory[3][coordhistoryptr]=wherePointing(coords,col,lin,scrx,scry,
|
||||
distanceAwayDisplay, baseToEdgeDistance, colorBase,
|
||||
colorEdge, screensize);
|
||||
}
|
||||
else {endScreenControl(scrctrl);return 2;};
|
||||
if ((workingMethod==0)||(workingMethod==1)||(workingMethod==2)||(workingMethod==3))
|
||||
coordhistory[3][coordhistoryptr]=proportionWebcamToScreen(mx,my,col,lin,scrx,scry,inputoffset);
|
||||
smoothedcoords[3]=smootherPoints(coordhistory[3],coordhistoryptr,smoothNumberFrames);
|
||||
//printf("%04d,%03d=<o>=%04d,%03d\n",mx,my,smoothedcoords[3].x,smoothedcoords[3].y);
|
||||
//printf("%04d,%03d=<o>=%04d,%03d\n",col,lin,scrx,scry);
|
||||
if ((workingMethod==3) || (workingMethod==4))
|
||||
{
|
||||
dist[0] = euclideanDistance(smoothedcoords[0],smoothedcoords[1] ); //bg
|
||||
dist[1] = euclideanDistance( smoothedcoords[1],smoothedcoords[2]); //rg
|
||||
dist[2] = euclideanDistance(smoothedcoords[0], smoothedcoords[2]); //br
|
||||
for (k=0;k<cn;k++)
|
||||
bdist[k] = (dist[k]<dtrig);
|
||||
clickcond = ((((bdist[2]<<1)+bdist[1])<<1)+bdist[0]);
|
||||
};
|
||||
//printf("%d--%d-%d-%d--%03d-%03d-%03d\n",clickcond,bdist[0],bdist[1],bdist[2],dist[0],dist[1],dist[2]);
|
||||
//MOUSE EVENTS - DOING
|
||||
gotoMouse(scrctrl,smoothedcoords[3]);
|
||||
if ((workingMethod==3) || (workingMethod==4))
|
||||
{
|
||||
if (workingMethod==3)
|
||||
{
|
||||
switch(clickcond)
|
||||
{
|
||||
case 0: clickcode=0;
|
||||
case 1: clickcode=1;
|
||||
case 2: clickcode=2;
|
||||
case 3: clickcode=0;
|
||||
case 4: clickcode=3;
|
||||
case 5: clickcode=0;
|
||||
case 6: clickcode=1;
|
||||
case 7: clickcode=1;
|
||||
};
|
||||
}
|
||||
else if (workingMethod==4)
|
||||
{
|
||||
if ((euclideanDistance(smoothedcoords[colorBase],smoothedcoords[colorClicker])<dtrig)&&(!((bool)clickingDisabled)))
|
||||
clickcode=1;
|
||||
else
|
||||
clickcode=0;
|
||||
}
|
||||
else {endScreenControl(scrctrl);return 127;};
|
||||
clickCode(scrctrl,clickcode);
|
||||
};
|
||||
coordhistoryptr++;
|
||||
}
|
||||
endScreenControl(scrctrl);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
//This was necessary for testing purposes, and may be outdated now
|
||||
#ifndef THIS_IS_THE_FILE_THAT_HOLDS_THE_MAIN
|
||||
#define THIS_IS_THE_FILE_THAT_HOLDS_THE_MAIN
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//initialiazing mouse control
|
||||
Display *disp = NULL;
|
||||
disp = XOpenDisplay (NULL);
|
||||
Screen* scrn = DefaultScreenOfDisplay(disp);
|
||||
int ty = scrn->height;
|
||||
int tx = scrn->width;
|
||||
//entering loop
|
||||
theCoolPart(0,5,0,disp,tx,ty);
|
||||
//closing mouse control
|
||||
XCloseDisplay(disp);
|
||||
return 0;
|
||||
};
|
||||
#endif // THIS_IS_THE_FILE_THAT_HOLDS_THE_MAIN
|
||||
*/
|
|
@ -0,0 +1,444 @@
|
|||
#ifndef CORE_H
|
||||
#define CORE_H
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <math.h>
|
||||
|
||||
struct coordinate {int x; int y; }; typedef struct coordinate coordinate;
|
||||
struct coord3d {double x; double y; double z;}; typedef struct coord3d coord3d;
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
#ifndef _MATH_H
|
||||
#define _MATH_H
|
||||
|
||||
int pow(int a, int b)
|
||||
{
|
||||
int o=1;
|
||||
int t;
|
||||
for (t=0;t<b;t++)
|
||||
o*=a;
|
||||
return o;
|
||||
}
|
||||
|
||||
int sqrt(int i)
|
||||
{
|
||||
if (i==0) return 0;
|
||||
if (i==1) return 1;
|
||||
if (i<0) return sqrt(-i);
|
||||
int o=1;
|
||||
while (!((pow(o,2)<=i) && (pow(o+1,2)>i)))
|
||||
{
|
||||
o++;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
#endif // _MATH_H
|
||||
|
||||
|
||||
double deg2rad(double i)
|
||||
{
|
||||
return (i*(M_PI/180.0));
|
||||
}
|
||||
|
||||
double rad2deg(double i)
|
||||
{
|
||||
return (i*(180.0/M_PI));
|
||||
}
|
||||
|
||||
double euclideanDistance(coordinate in1, coordinate in2)
|
||||
{
|
||||
double f;
|
||||
long long int dx,dy;
|
||||
double t;
|
||||
dx = ((in1.x)-(in2.x));
|
||||
dy = ((in1.y)-(in2.y));
|
||||
t = pow(dx,2) + pow(dy,2);
|
||||
f = sqrt(t);
|
||||
return f;
|
||||
}
|
||||
|
||||
double pitagoras(double cat1, double cat2)
|
||||
{
|
||||
return sqrt(pow(cat1,2)+pow(cat2,2));
|
||||
}
|
||||
|
||||
void swapCoord(coordinate *in1, coordinate *in2)
|
||||
{
|
||||
coordinate *tmp = in1;
|
||||
in1 = in2;
|
||||
in2 = tmp;
|
||||
return;
|
||||
}
|
||||
|
||||
void swapInt(int *in1, int *in2)
|
||||
{
|
||||
int *tmp = in1;
|
||||
in1 = in2;
|
||||
in2 = tmp;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __unix__ //works perfectly on linux; why not in windows?
|
||||
coordinate bestIlluminati(Mat inmage, int lin, int col, int layer)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int sx=inmage.step[1];
|
||||
int sy=inmage.step[0];
|
||||
char v;
|
||||
coordinate vec1[lin*col];
|
||||
coordinate vec2[lin*col];
|
||||
uint8_t* pixelPtr;
|
||||
pixelPtr = (uint8_t*)inmage.data;
|
||||
char vec1val=0;
|
||||
char vec2val=0;
|
||||
long int vec1len=0;
|
||||
long int vec2len=0;
|
||||
for (y=0; y<lin; y++)
|
||||
{for (x=0; x<col; x++)
|
||||
{
|
||||
v=*(pixelPtr+((sx*x)+(y*sy)+(layer)));
|
||||
if (((int)vec1val)==((int)v))
|
||||
{
|
||||
vec1[vec1len].x=x;
|
||||
vec1[vec1len].y=y;
|
||||
vec1len++;
|
||||
}
|
||||
else if (((int)vec2val)==((int)v))
|
||||
{
|
||||
vec2[vec2len].x=x;
|
||||
vec2[vec2len].y=y;
|
||||
vec2len++;
|
||||
}
|
||||
else if (((int)vec1val)<((int)v))
|
||||
{
|
||||
vec2len=vec1len;
|
||||
vec2val=vec1val;
|
||||
swapCoord(vec1,vec2);
|
||||
vec1val=v;
|
||||
vec1len=0;
|
||||
vec1[vec1len].x=x;
|
||||
vec1[vec1len].y=y;
|
||||
vec1len++;
|
||||
}
|
||||
else if ((((int)vec1val)>((int)v))&&(((int)v)>((int)vec2val)))
|
||||
{
|
||||
vec2val=v;
|
||||
vec2len=0;
|
||||
vec2[vec2len].x=x;
|
||||
vec2[vec2len].y=y;
|
||||
vec2len++;
|
||||
};
|
||||
};};
|
||||
/////////////////////////////////////
|
||||
long long int sv1x=0;
|
||||
long long int sv1y=0;
|
||||
long long int sv2x=0;
|
||||
long long int sv2y=0;
|
||||
for (x=0; x<vec1len; x++)
|
||||
{
|
||||
sv1x+=vec1[x].x;
|
||||
sv1y+=vec1[x].y;
|
||||
};
|
||||
for (x=0; x<vec2len; x++)
|
||||
{
|
||||
sv2x+=vec2[x].x;
|
||||
sv2y+=vec2[x].y;
|
||||
};
|
||||
int v1x=0;
|
||||
int v1y=0;
|
||||
if (vec1len>0)
|
||||
{
|
||||
v1x=sv1x/vec1len;
|
||||
v1y=sv1y/vec1len;
|
||||
}
|
||||
else {struct coordinate retVal; retVal.x=0; retVal.y=0; return retVal;};
|
||||
int v2x=v1x;
|
||||
int v2y=v1y;
|
||||
if (vec2len>0)
|
||||
{
|
||||
v2x=sv2x/vec2len;
|
||||
v2y=sv2y/vec2len;
|
||||
};
|
||||
//////////////////////
|
||||
struct coordinate retVal;
|
||||
retVal.x=((2*v1x)+(v2x))/3;
|
||||
retVal.y=((2*v1y)+(v2y))/3;
|
||||
return retVal;
|
||||
}
|
||||
#endif //unix
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
|
||||
coordinate bestIlluminati(Mat inmage, int lin, int col, int layer)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int sx=inmage.step[1];
|
||||
int sy=inmage.step[0];
|
||||
char v;
|
||||
long long int tmp=lin*col*2;
|
||||
int *vec1=(int*)malloc(sizeof(int)*tmp);
|
||||
int *vec2=(int*)malloc(sizeof(int)*tmp);
|
||||
uint8_t* pixelPtr;
|
||||
pixelPtr = (uint8_t*)inmage.data;
|
||||
char vec1val=0;
|
||||
char vec2val=0;
|
||||
long int vec1len=0;
|
||||
long int vec2len=0;
|
||||
for (y=0; y<lin; y++)
|
||||
{for (x=0; x<col; x++)
|
||||
{
|
||||
v=*(pixelPtr+((sx*x)+(y*sy)+(layer)));
|
||||
if (((int)vec1val)==((int)v))
|
||||
{
|
||||
vec1[0+2*vec1len]=x;
|
||||
vec1[1+2*vec1len]=y;
|
||||
vec1len++;
|
||||
}
|
||||
else if (((int)vec2val)==((int)v))
|
||||
{
|
||||
vec2[0+2*vec2len]=x;
|
||||
vec2[1+2*vec2len]=y;
|
||||
vec2len++;
|
||||
}
|
||||
else if (((int)vec1val)<((int)v))
|
||||
{
|
||||
vec2len=vec1len;
|
||||
vec2val=vec1val;
|
||||
swapInt(vec1,vec2);
|
||||
vec1val=v;
|
||||
vec1len=0;
|
||||
vec1[0+2*vec1len]=x;
|
||||
vec1[1+2*vec1len]=y;
|
||||
vec1len++;
|
||||
}
|
||||
else if ((((int)vec1val)>((int)v))&&(((int)v)>((int)vec2val)))
|
||||
{
|
||||
vec2val=v;
|
||||
vec2len=0;
|
||||
vec2[0+2*vec2len]=x;
|
||||
vec2[1+2*vec2len]=y;
|
||||
vec2len++;
|
||||
};
|
||||
};};
|
||||
/////////////////////////////////////
|
||||
long long int sv1x=0;
|
||||
long long int sv1y=0;
|
||||
long long int sv2x=0;
|
||||
long long int sv2y=0;
|
||||
for (x=0; x<vec1len; x++)
|
||||
{
|
||||
sv1x+=vec1[0+2*x];
|
||||
sv1y+=vec1[1+2*x];
|
||||
};
|
||||
for (x=0; x<vec2len; x++)
|
||||
{
|
||||
sv2x+=vec2[0+2*x];
|
||||
sv2y+=vec2[1+2*x];
|
||||
};
|
||||
free(vec1);
|
||||
free(vec2);
|
||||
int v1x=0;
|
||||
int v1y=0;
|
||||
if (vec1len>0)
|
||||
{
|
||||
v1x=sv1x/vec1len;
|
||||
v1y=sv1y/vec1len;
|
||||
}
|
||||
else {struct coordinate retVal; retVal.x=0; retVal.y=0; return retVal;};
|
||||
int v2x=v1x;
|
||||
int v2y=v1y;
|
||||
if (vec2len>0)
|
||||
{
|
||||
v2x=sv2x/vec2len;
|
||||
v2y=sv2y/vec2len;
|
||||
};
|
||||
//////////////////////
|
||||
struct coordinate retVal;
|
||||
retVal.x=((2*v1x)+(v2x))/3;
|
||||
retVal.y=((2*v1y)+(v2y))/3;
|
||||
return retVal;
|
||||
}
|
||||
#endif //win32
|
||||
|
||||
#if defined(__unix__) || defined(_WIN32)
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
|
||||
void makeSelectionVisible(Mat inmage, int sel, int cn, int lins, int cols, coordinate co)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int sx=inmage.step[1];
|
||||
int sy=inmage.step[0];
|
||||
int k;
|
||||
uint8_t *pixelPtr;
|
||||
pixelPtr = (uint8_t*)inmage.data;
|
||||
x=co.x;
|
||||
y=co.y;
|
||||
for (y=0; y<lins; y++)
|
||||
{
|
||||
for (k=0;k<cn;k++)
|
||||
{
|
||||
if (sel==k)
|
||||
{
|
||||
*(pixelPtr+((sx*x)+(y*sy)+(k)))=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(pixelPtr+((sx*x)+(y*sy)+(k)))=0;
|
||||
};
|
||||
};
|
||||
};
|
||||
x=co.x;
|
||||
y=co.y;
|
||||
for (x=0; x<cols; x++)
|
||||
{
|
||||
for (k=0;k<cn;k++)
|
||||
{
|
||||
if (sel==k)
|
||||
{
|
||||
*(pixelPtr+((sx*x)+(y*sy)+(k)))=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(pixelPtr+((sx*x)+(y*sy)+(k)))=0;
|
||||
};
|
||||
};
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
coordinate smootherPoints(coordinate *coordhistory, int coordhistoryptr, int smoothNumberFrames)
|
||||
{
|
||||
int l;
|
||||
int m;
|
||||
long int sx=0;
|
||||
long int sy=0;
|
||||
coordinate crdnt;
|
||||
for (l=0;l<smoothNumberFrames;l++)
|
||||
{
|
||||
m=(coordhistoryptr+l)%smoothNumberFrames;
|
||||
sx+=coordhistory[m].x;
|
||||
sy+=coordhistory[m].y;
|
||||
};
|
||||
crdnt.x=(int)(sx/smoothNumberFrames);
|
||||
crdnt.y=(int)(sy/smoothNumberFrames);
|
||||
return crdnt;
|
||||
};
|
||||
|
||||
coordinate proportionWebcamToScreen(float basex, float basey, int wcrx, int wcry, int scrx, int scry, int offprop)
|
||||
{
|
||||
coordinate m;
|
||||
float mx;
|
||||
float my;
|
||||
float ex;
|
||||
float ey;
|
||||
float ax;
|
||||
float ay;
|
||||
ex=(wcrx*(offprop/100.0));
|
||||
ey=(wcry*(offprop/100.0));
|
||||
ax=(wcrx-(2*ex));
|
||||
ay=(wcry-(2*ey));
|
||||
////
|
||||
if (basex<ex)
|
||||
mx=0;
|
||||
else if (basex>(ex+ax))
|
||||
mx=scrx-1;
|
||||
else
|
||||
mx=((basex-ex)/((float)ax))*scrx;
|
||||
////
|
||||
if (basey<ey)
|
||||
my=0;
|
||||
else if (basey>(ey+ay))
|
||||
my=scry-1;
|
||||
else
|
||||
my=((basey-ey)/((float)ay))*scry;
|
||||
////
|
||||
m.x = mx;
|
||||
m.y = my;
|
||||
return m;
|
||||
}
|
||||
|
||||
double cameraPX2CM(double camAngle, double distInCm, int pixAmm)
|
||||
{
|
||||
return ((sin(camAngle)*distInCm)/pixAmm);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
coordinate wherePointing(coordinate* coords, int wcrx, int wcry, int scrx, int scry,
|
||||
int distanceAwayDisplay, int baseToEdgeDistance, int colorBase,
|
||||
int colorEdge, int screensize)
|
||||
{
|
||||
//printf("%d,%d\n",colorBase,colorEdge);
|
||||
double camAngle = deg2rad(60)/2; //read as FOV
|
||||
coord3d base;
|
||||
coord3d edge;
|
||||
double p2c=cameraPX2CM(camAngle,distanceAwayDisplay,scrx/4);
|
||||
double distanceBaseEdge=euclideanDistance(coords[colorBase],coords[colorEdge])*p2c;
|
||||
if (distanceBaseEdge>baseToEdgeDistance)
|
||||
distanceBaseEdge=baseToEdgeDistance;
|
||||
double zangle=acos(distanceBaseEdge/baseToEdgeDistance);
|
||||
//printf("%f\n",cameraPX2CM(camAngle,distanceAwayDisplay,wcrx/2));
|
||||
//
|
||||
base.z=distanceAwayDisplay;
|
||||
base.x=(distanceAwayDisplay*((sin(camAngle)*(coords[colorBase].x/((double)wcrx)))-0.5));
|
||||
base.y=(distanceAwayDisplay*((sin(camAngle)*(coords[colorBase].y/((double)wcry)))-0.5));
|
||||
//printf("%05.1f -- %05.1f -- %05.1f\n",base.x,base.y,base.z);
|
||||
//
|
||||
double angle = atan2(coords[colorBase].y-coords[colorEdge].y, coords[colorBase].x-coords[colorEdge].x);
|
||||
//printf("% 6.1f\n",rad2deg(angle));
|
||||
//
|
||||
edge.x=base.x+(distanceBaseEdge*cos(angle));
|
||||
edge.y=base.y+(distanceBaseEdge*sin(angle));
|
||||
edge.z=distanceAwayDisplay-(baseToEdgeDistance*cos(zangle));
|
||||
//printf("%05.1f -- %05.1f\n",zangle,cos(zangle));
|
||||
//printf("%05.1f -- %05.1f -- %05.1f\n",edge.x,edge.y,edge.z);
|
||||
//
|
||||
coord3d delta;
|
||||
delta.x=base.x-edge.x;
|
||||
delta.y=base.y-edge.y;
|
||||
delta.z=base.z-edge.z;
|
||||
if (delta.z==0)
|
||||
delta.z=0.002;
|
||||
//printf("%05.1f -- %05.1f -- %05.1f\n",delta.x,delta.y,delta.z);
|
||||
//
|
||||
double px,py;
|
||||
int dx,dy;
|
||||
dx=scrx/2;
|
||||
dy=scry/2;
|
||||
px=((((distanceAwayDisplay*cos(zangle))/delta.z)*delta.x)/p2c);
|
||||
py=((((distanceAwayDisplay*cos(zangle))/delta.z)*delta.y)/p2c);
|
||||
px*=sqrt(screensize);
|
||||
py*=sqrt(screensize);
|
||||
px+=dx;
|
||||
py+=dy;
|
||||
//printf("%d\n",screensize);
|
||||
/*
|
||||
px+=wcrx/2;
|
||||
py+=wcry/2;*/
|
||||
//(screensize*2.54)
|
||||
/*
|
||||
* Here the projections PX and PY are scaled as*/
|
||||
//printf("%05.1f -- %05.1f\n",px,py);
|
||||
coordinate ret;
|
||||
ret=proportionWebcamToScreen(px,py,scrx,scry,scrx,scry,0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
void clickedInImage(int event, int x, int y, int flags, void* userdata){
|
||||
if(event == EVENT_LBUTTONDOWN || event == EVENT_RBUTTONDOWN || event == EVENT_MBUTTONDOWN) GVAR1=1;
|
||||
else GVAR1=0;
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
#endif // CORE_H
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef CORE_INCLUDESPEROS_H
|
||||
#define CORE_INCLUDESPEROS_H
|
||||
//Windows.
|
||||
#ifdef _WIN32
|
||||
#include "disp.win32.cpp"
|
||||
#endif //_WIN32
|
||||
|
||||
//Android.
|
||||
#ifdef __ANDROID__
|
||||
#error: Your platform isnt supported yet.
|
||||
#else
|
||||
|
||||
//Mac.
|
||||
#ifdef __APPLE__
|
||||
#error: Your platform isnt supported yet.
|
||||
#else
|
||||
|
||||
//Any unix-like OS, that must not be a Mac. --Expects X11--
|
||||
#ifdef __unix__
|
||||
#include "disp.x11.cpp"
|
||||
#endif //LINUX or UNIX
|
||||
#endif //MACOSX
|
||||
#endif //ANDROID
|
||||
#endif // CORE_INCLUDESPEROS_H
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef CORE_STRUCTS_H
|
||||
#define CORE_STRUCTS_H
|
||||
struct coordinate {int x; int y;};
|
||||
#endif // CORE_STRUCTS_H
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef WIN32_DISP_CPP
|
||||
#define WIN32_DISP_CPP
|
||||
#include <windows.h>
|
||||
|
||||
typedef unsigned char u_int8_t; //NOW WORKS !!!
|
||||
|
||||
struct screenControl {}; typedef struct screenControl screenControl;
|
||||
|
||||
/*
|
||||
void gotoMouse(screenControl, coordinate co) {
|
||||
COORD coord;
|
||||
coord.X = co.x;
|
||||
coord.Y = co.y;
|
||||
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
|
||||
}
|
||||
|
||||
void mouseclick{
|
||||
GetCursorPos(&pos_cursor);
|
||||
hwnd_outra_win = WindowFromPoint(pos_cursor);
|
||||
SendMessage(hwnd_outra_win,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(pos_cursor.x,pos_cursor.y));
|
||||
SendMessage(hwnd_outra_win,WM_LBUTTONUP,0,MAKELPARAM(pos_cursor.x,pos_cursor.y));
|
||||
}*/
|
||||
|
||||
|
||||
screenControl initScreenControl()
|
||||
{
|
||||
screenControl scr;
|
||||
return scr;
|
||||
}
|
||||
|
||||
void endScreenControl(screenControl scr)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
coordinate ScrSize(screenControl scr)
|
||||
{
|
||||
coordinate sz;
|
||||
RECT desktop;
|
||||
HWND hDesktop = GetDesktopWindow();
|
||||
GetWindowRect(hDesktop, &desktop);
|
||||
sz.x=desktop.right;
|
||||
sz.y=desktop.bottom;
|
||||
return sz;
|
||||
}
|
||||
|
||||
void gotoMouse(screenControl sc, coordinate co)
|
||||
{
|
||||
coordinate s;
|
||||
s=ScrSize(sc);
|
||||
INPUT thisInput = { 0 };
|
||||
thisInput.type = INPUT_MOUSE;
|
||||
thisInput.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
|
||||
thisInput.mi.dx = (LONG)(long int)((65536/((float)s.x))*co.x);
|
||||
thisInput.mi.dy = (LONG)(long int)((65536/((float)s.y))*co.y);
|
||||
SendInput(1, &thisInput, sizeof(INPUT));
|
||||
}
|
||||
|
||||
void clickCode(screenControl sc, int code)
|
||||
{
|
||||
INPUT thisInput = { 0 };
|
||||
thisInput.type = INPUT_MOUSE;
|
||||
if (code==1) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
|
||||
if (code!=1) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP;
|
||||
SendInput(1, &thisInput, sizeof(INPUT));
|
||||
if (code==2) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTDOWN;
|
||||
if (code!=2) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP;
|
||||
SendInput(1, &thisInput, sizeof(INPUT));
|
||||
if (code==3) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MIDDLEDOWN;
|
||||
if (code!=3) thisInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MIDDLEUP;
|
||||
SendInput(1, &thisInput, sizeof(INPUT));
|
||||
}
|
||||
|
||||
#endif //WIN32_DISP_CPP
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef LINUX_DISP_CPP
|
||||
#define LINUX_DISP_CPP
|
||||
#include <X11/extensions/XTest.h>
|
||||
|
||||
/* //The coordinate structure isn't recognized by IDE (Qt Creator), but is recognized by compiler (g++).
|
||||
struct coordinate {int x; int y;}; typedef struct coordinate coordinate;*/
|
||||
struct screenControl {Display *disp; XEvent event; Screen *screen;}; typedef struct screenControl screenControl;
|
||||
|
||||
screenControl initScreenControl()
|
||||
{
|
||||
screenControl scr;
|
||||
scr.disp = XOpenDisplay(NULL);
|
||||
scr.screen = DefaultScreenOfDisplay(scr.disp);
|
||||
return scr;
|
||||
}
|
||||
|
||||
void endScreenControl(screenControl scr)
|
||||
{
|
||||
XCloseDisplay(scr.disp);
|
||||
}
|
||||
|
||||
coordinate ScrSize(screenControl scr)
|
||||
{
|
||||
coordinate sz;
|
||||
sz.x = scr.screen->width;
|
||||
sz.y = scr.screen->height;
|
||||
return sz;
|
||||
}
|
||||
|
||||
void gotoMouse(screenControl sc, coordinate co)
|
||||
{
|
||||
XTestFakeMotionEvent(sc.disp, 0, co.x, co.y, CurrentTime);
|
||||
XSync(sc.disp, 0);
|
||||
}
|
||||
|
||||
void clickCode(screenControl sc, int code)
|
||||
{
|
||||
if (code==1) XTestFakeButtonEvent(sc.disp, Button1, true, CurrentTime);
|
||||
if (code==2) XTestFakeButtonEvent(sc.disp, Button2, true, CurrentTime);
|
||||
if (code==3) XTestFakeButtonEvent(sc.disp, Button3, true, CurrentTime);
|
||||
if (code==4) XTestFakeButtonEvent(sc.disp, Button4, true, CurrentTime);
|
||||
if (code==5) XTestFakeButtonEvent(sc.disp, Button5, true, CurrentTime);
|
||||
if (code!=1) XTestFakeButtonEvent(sc.disp, Button1, false, CurrentTime);
|
||||
if (code!=2) XTestFakeButtonEvent(sc.disp, Button2, false, CurrentTime);
|
||||
if (code!=3) XTestFakeButtonEvent(sc.disp, Button3, false, CurrentTime);
|
||||
if (code!=4) XTestFakeButtonEvent(sc.disp, Button4, false, CurrentTime);
|
||||
if (code!=5) XTestFakeButtonEvent(sc.disp, Button5, false, CurrentTime);
|
||||
XSync(sc.disp, 0);
|
||||
}
|
||||
|
||||
#endif //LINUX_DISP_CPP
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{FB059199-C5DC-405B-883D-048B3808E33E}</ProjectGuid>
|
||||
<Compiler>
|
||||
<Compiler ctype="GppCompiler" />
|
||||
</Compiler>
|
||||
<Language>CPP</Language>
|
||||
<Target>Bin</Target>
|
||||
<Packages>
|
||||
<Packages>
|
||||
<Package file="/usr/local/lib/pkgconfig/opencv.pc" name="OpenCV" IsProject="False" />
|
||||
<Package file="/usr/lib/x86_64-linux-gnu/pkgconfig/xtst.pc" name="Xtst" IsProject="False" />
|
||||
<Package file="/usr/lib/x86_64-linux-gnu/pkgconfig/x11.pc" name="X11" IsProject="False" />
|
||||
</Packages>
|
||||
</Packages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<OutputName>CPP</OutputName>
|
||||
<CompileTarget>Bin</CompileTarget>
|
||||
<DefineSymbols>DEBUG MONODEVELOP</DefineSymbols>
|
||||
<SourceDirectory>.</SourceDirectory>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<OutputName>CPP</OutputName>
|
||||
<CompileTarget>Bin</CompileTarget>
|
||||
<OptimizationLevel>3</OptimizationLevel>
|
||||
<DefineSymbols>MONODEVELOP</DefineSymbols>
|
||||
<SourceDirectory>.</SourceDirectory>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="core.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{2857B73E-F847-4B02-9238-064979017E93}") = "webCAMotion", "webCAMotion.cproj", "{FB059199-C5DC-405B-883D-048B3808E33E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FB059199-C5DC-405B-883D-048B3808E33E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FB059199-C5DC-405B-883D-048B3808E33E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB059199-C5DC-405B-883D-048B3808E33E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB059199-C5DC-405B-883D-048B3808E33E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = webCAMotion.cproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,12 @@
|
|||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="core.cpp">
|
||||
<Files>
|
||||
<File FileName="core.cpp" Line="272" Column="34" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
</Properties>
|
|
@ -0,0 +1,83 @@
|
|||
#include "errormsgafterfailure.h"
|
||||
#include "ui_errormsgafterfailure.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <QShortcut>
|
||||
|
||||
using namespace std;
|
||||
|
||||
static QString errorcode="Error code: NUM";
|
||||
static QString errordesc="Description: DESC";
|
||||
|
||||
int charsize(char* in)
|
||||
{
|
||||
int cz=0;
|
||||
while (*(in+cz)!=0) cz++;
|
||||
return cz;
|
||||
}
|
||||
|
||||
int wchartsize(wchar_t* in)
|
||||
{
|
||||
int cz=0;
|
||||
while (*(in+cz)!=0) cz++;
|
||||
return cz;
|
||||
}
|
||||
|
||||
wchar_t *char2wchart(char *in)
|
||||
{
|
||||
int sz=charsize(in);
|
||||
static wchar_t out[255];
|
||||
int k=0;
|
||||
for (k=0;k<sz;k++) out[k]=in[k];
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
(ノಠ益ಠ)ノ彡┻━┻
|
||||
ಠ_ರೃ
|
||||
ಠ~ಠ
|
||||
ಠ╭╮ಠ
|
||||
ಠ▃ಠ
|
||||
ಥ_ಥ
|
||||
┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
|
||||
*/
|
||||
|
||||
errorMsgAfterFailure::errorMsgAfterFailure(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::errorMsgAfterFailure)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QShortcut *shortcut = new QShortcut(QKeySequence("Esc"), this);
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(justClose()));
|
||||
ui->meme->setText(QString::fromUtf8("┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻"));
|
||||
/*ui->meme->setText(QString::fromUtf8("(ノಠ益ಠ)ノ彡┻━┻"));*/
|
||||
}
|
||||
|
||||
void errorMsgAfterFailure::setErrorCode(int in)
|
||||
{
|
||||
char tmp[255];
|
||||
int k=0;
|
||||
for (k=0;k<255;k++) tmp[k]=0;
|
||||
snprintf(tmp,254,"Error code: %d",in);
|
||||
wchar_t tmp2[255];
|
||||
for (k=0;k<255;k++) tmp2[k]=tmp[k];
|
||||
errorcode=QString::fromWCharArray(tmp2,wchartsize(tmp2));
|
||||
ui->errcode->setText(errorcode);
|
||||
}
|
||||
|
||||
void errorMsgAfterFailure::setErrorDesc(std::string in)
|
||||
{
|
||||
errordesc=QString::fromStdString("Description: " + in);
|
||||
ui->errdesc->setText(errordesc);
|
||||
}
|
||||
|
||||
errorMsgAfterFailure::~errorMsgAfterFailure()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void errorMsgAfterFailure::justClose() {window()->close();}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef ERRORMSGAFTERFAILURE_H
|
||||
#define ERRORMSGAFTERFAILURE_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class errorMsgAfterFailure;
|
||||
}
|
||||
|
||||
class errorMsgAfterFailure : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit errorMsgAfterFailure(QWidget *parent = 0);
|
||||
~errorMsgAfterFailure();
|
||||
|
||||
public slots:
|
||||
void justClose();
|
||||
void setErrorCode(int in);
|
||||
void setErrorDesc(std::string in);
|
||||
|
||||
private:
|
||||
Ui::errorMsgAfterFailure *ui;
|
||||
};
|
||||
|
||||
#endif // ERRORMSGAFTERFAILURE_H
|
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>errorMsgAfterFailure</class>
|
||||
<widget class="QDialog" name="errorMsgAfterFailure">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>164</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>(ノಠ益ಠ)ノ彡┻━┻</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="meme">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Sans Serif</family>
|
||||
<pointsize>18</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MEME</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>An error unfortunately happened...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errcode">
|
||||
<property name="text">
|
||||
<string>Error code: NUM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errdesc">
|
||||
<property name="text">
|
||||
<string>Description: DESC</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>108</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>108</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||