filmout_display now loads a blank image on startup and displays it. Logic for loading and displaying arbitrary images still needed.
This commit is contained in:
parent
4a68abd38e
commit
78cca62c12
|
@ -34,8 +34,8 @@ class State {
|
||||||
vector<uint64_t> exposure = {};
|
vector<uint64_t> exposure = {};
|
||||||
uint64_t x;
|
uint64_t x;
|
||||||
uint64_t y;
|
uint64_t y;
|
||||||
uint64_t width;
|
uint64_t w;
|
||||||
uint64_t height;
|
uint64_t h;
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool ERROR = false;
|
bool ERROR = false;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class State {
|
||||||
Mode getMode() { return mode; }
|
Mode getMode() { return mode; }
|
||||||
string getImage () { return image; }
|
string getImage () { return image; }
|
||||||
vector<uint64_t> getExposure() { return exposure; }
|
vector<uint64_t> getExposure() { return exposure; }
|
||||||
vector<uint64_t> getPosition() { return { x, y, width, height }; }
|
vector<uint64_t> getPosition() { return { x, y, w, h }; }
|
||||||
bool isError () { return ERROR; }
|
bool isError () { return ERROR; }
|
||||||
void setActive () { active = true; }
|
void setActive () { active = true; }
|
||||||
bool isActive () { return active; }
|
bool isActive () { return active; }
|
||||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -25,8 +25,8 @@ using namespace std;
|
||||||
const uint16_t PORT = 8081;
|
const uint16_t PORT = 8081;
|
||||||
const uint16_t BUFFER_SIZE = 2048;
|
const uint16_t BUFFER_SIZE = 2048;
|
||||||
|
|
||||||
GLuint imageTexture;
|
GLuint imageTexture = 0;
|
||||||
GLuint blankTexture;
|
GLuint blankTexture = 0;
|
||||||
|
|
||||||
GLint screenWidth = 0;
|
GLint screenWidth = 0;
|
||||||
GLint screenHeight = 0;
|
GLint screenHeight = 0;
|
||||||
|
@ -34,8 +34,6 @@ GLint screenHeight = 0;
|
||||||
Image img;
|
Image img;
|
||||||
State state;
|
State state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void actionDisplay () {
|
void actionDisplay () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,9 +68,9 @@ void actionStop () {
|
||||||
|
|
||||||
void loadBlank () {
|
void loadBlank () {
|
||||||
Mat blank = img.getBlank();
|
Mat blank = img.getBlank();
|
||||||
|
|
||||||
glGenTextures(1, &blankTexture);
|
glGenTextures(1, &blankTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, blankTexture);
|
glBindTexture(GL_TEXTURE_2D, blankTexture);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
@ -97,7 +95,7 @@ void display () {
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||||
glBindTexture(GL_TEXTURE_2D, imageTexture);
|
glBindTexture(GL_TEXTURE_2D, blankTexture);
|
||||||
|
|
||||||
glBegin(GL_QUADS); // front face
|
glBegin(GL_QUADS); // front face
|
||||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f); //bottom right
|
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f); //bottom right
|
||||||
|
@ -112,6 +110,11 @@ void display () {
|
||||||
//glFlush();
|
//glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void timer(int value) {
|
||||||
|
glutPostRedisplay();
|
||||||
|
glutTimerFunc(1, timer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State Message Variables
|
* State Message Variables
|
||||||
**/
|
**/
|
||||||
|
@ -234,6 +237,7 @@ uint8_t handleArgs (int argc, char** argv) {
|
||||||
cerr << "Please provide screen height as second argument" << endl;
|
cerr << "Please provide screen height as second argument" << endl;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
cout << screenWidth << "x" << screenHeight << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,15 +250,14 @@ int main (int argc, char** argv) {
|
||||||
|
|
||||||
img.setDimensions( (uint16_t) screenWidth, (uint16_t) screenHeight);
|
img.setDimensions( (uint16_t) screenWidth, (uint16_t) screenHeight);
|
||||||
|
|
||||||
loadBlank();
|
|
||||||
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
glutInitDisplayMode(GLUT_SINGLE);
|
glutInitDisplayMode(GLUT_SINGLE);
|
||||||
glutCreateWindow("opengl_opencv_example");
|
glutCreateWindow("opengl_opencv_example");
|
||||||
glutSetCursor(GLUT_CURSOR_NONE);
|
glutSetCursor(GLUT_CURSOR_NONE);
|
||||||
glutFullScreen();
|
glutFullScreen();
|
||||||
glutDisplayFunc(display);
|
glutDisplayFunc(display);
|
||||||
glutMainLoop();
|
glutTimerFunc(0, timer, 0);
|
||||||
|
loadBlank();
|
||||||
|
|
||||||
int serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
int serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (serverSocket < 0) {
|
if (serverSocket < 0) {
|
||||||
|
@ -282,10 +285,11 @@ int main (int argc, char** argv) {
|
||||||
cout << "TCP server listening on port " << PORT << endl;
|
cout << "TCP server listening on port " << PORT << endl;
|
||||||
|
|
||||||
thread serverThread(runTCPServer, serverSocket);
|
thread serverThread(runTCPServer, serverSocket);
|
||||||
|
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
serverThread.join();
|
serverThread.join();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
close(serverSocket);
|
close(serverSocket);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -37,9 +37,9 @@ void State::setMode (json& msgData) {
|
||||||
void State::setPosition (json& msgData) {
|
void State::setPosition (json& msgData) {
|
||||||
x = msgData["position"]["x"];
|
x = msgData["position"]["x"];
|
||||||
y = msgData["position"]["y"];
|
y = msgData["position"]["y"];
|
||||||
width = msgData["position"]["w"];
|
w = msgData["position"]["w"];
|
||||||
height = msgData["position"]["h"];
|
h = msgData["position"]["h"];
|
||||||
cout << "Position[x] = " << x << " [y] = " << y << " [width] = " << width << " [height] = " << height << endl;
|
cout << "Position[x] = " << x << " [y] = " << y << " [w] = " << w << " [h] = " << h << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void State::setExposure (json& msgData) {
|
void State::setExposure (json& msgData) {
|
||||||
|
|
Loading…
Reference in New Issue