Update from upstream
This commit is contained in:
parent
c7a72ad9d4
commit
1ef6d9959d
3 changed files with 26 additions and 9 deletions
|
@ -39,6 +39,8 @@ THE SOFTWARE.
|
|||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
const int MAX = 16;
|
||||
|
||||
const char *names[] = {
|
||||
"0",
|
||||
"1",
|
||||
|
@ -64,7 +66,6 @@ void cls()
|
|||
}
|
||||
|
||||
int baseport = 4000;
|
||||
const int MAX = 16;
|
||||
|
||||
const int BUFLEN = 1024*1024; // in bytes
|
||||
//const int ABUFLEN = 1024; // in words
|
||||
|
@ -72,6 +73,12 @@ const int BUFLEN = 1024*1024; // in bytes
|
|||
// Yes this is ugly. :P
|
||||
bool failure = false;
|
||||
|
||||
#ifdef SHOWALL
|
||||
bool showall = true;
|
||||
#else
|
||||
bool showall = false;
|
||||
#endif
|
||||
|
||||
struct sockin {
|
||||
int listener_fd, data_fd;
|
||||
struct sockaddr_in serv_addr, cli_addr;
|
||||
|
@ -149,6 +156,8 @@ struct audio_sockin : public sockin {
|
|||
|
||||
const int IBUFLEN = 2048*1024; // in bytes
|
||||
|
||||
bool displayed = false;
|
||||
|
||||
struct image_sockin : public sockin {
|
||||
uint8_t buf[IBUFLEN];
|
||||
int bufsize;
|
||||
|
@ -158,16 +167,16 @@ struct image_sockin : public sockin {
|
|||
}
|
||||
|
||||
void showImage(int begin, int end, int listener) {
|
||||
if (listener == id) {
|
||||
if (showall || (listener == id)) {
|
||||
Mat imgbuf = cv::Mat(480, 640, CV_8U, &buf[begin]);
|
||||
Mat imgMat = cv::imdecode(imgbuf, CV_LOAD_IMAGE_COLOR);
|
||||
|
||||
if (!imgMat.data) cerr << "reading failed\r\n";
|
||||
// cerr << "x " << imgMat.rows << ' ' << imgMat.cols << "\r\n";
|
||||
|
||||
imshow("Display Window", imgMat);
|
||||
imshow(showall ? names[id] : "Display Window", imgMat);
|
||||
// cerr << "updated\r\n";
|
||||
waitKey(1);
|
||||
displayed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,9 +210,6 @@ struct image_sockin : public sockin {
|
|||
}
|
||||
|
||||
|
||||
// if (listener == id) {
|
||||
// if (have_fd3) write(3, data, len);
|
||||
// }
|
||||
}
|
||||
|
||||
virtual void newconn() {
|
||||
|
@ -273,7 +279,14 @@ int main(void)
|
|||
if (have_fd3) cerr << "Have video output socket\n";
|
||||
#endif
|
||||
// namedWindow("Display Window", WINDOW_AUTOSIZE );
|
||||
namedWindow("Display Window", WINDOW_AUTOSIZE );
|
||||
|
||||
if (showall) {
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
namedWindow(names[i], WINDOW_AUTOSIZE );
|
||||
}
|
||||
} else {
|
||||
namedWindow("Display Window", WINDOW_AUTOSIZE );
|
||||
}
|
||||
|
||||
// catch signals
|
||||
if (((void *)signal(SIGINT,sigcatch) < 0) ||
|
||||
|
@ -365,6 +378,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
displayed = false;
|
||||
for (int i = 0; (rv > 0) && (i < num_sockets); i++) {
|
||||
if (!s[i]) break;
|
||||
|
||||
|
@ -408,6 +422,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (displayed) waitKey(1);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue