Update from upstream

This commit is contained in:
Donald Burr 2015-02-17 21:34:09 -08:00
parent c7a72ad9d4
commit 1ef6d9959d
3 changed files with 26 additions and 9 deletions

View file

@ -3,6 +3,8 @@ host side:
apt-get install libopencv-dev apt-get install libopencv-dev
clang++ -O2 -lopencv_core -lopencv_highgui -lopencv_imgproc -o acatcher acatcher.cxx clang++ -O2 -lopencv_core -lopencv_highgui -lopencv_imgproc -o acatcher acatcher.cxx
(add -DSHOWALL to get all windows up at once, and change "const int MAX" to
reduce the number of windows up at once.)
to actually run it: to actually run it:
./acatcher | (aplay -t raw -c 1 -f S16_LE -r 22050 > /dev/null 2> /dev/null) ./acatcher | (aplay -t raw -c 1 -f S16_LE -r 22050 > /dev/null 2> /dev/null)

View file

@ -39,6 +39,8 @@ THE SOFTWARE.
using namespace cv; using namespace cv;
using namespace std; using namespace std;
const int MAX = 16;
const char *names[] = { const char *names[] = {
"0", "0",
"1", "1",
@ -64,7 +66,6 @@ void cls()
} }
int baseport = 4000; int baseport = 4000;
const int MAX = 16;
const int BUFLEN = 1024*1024; // in bytes const int BUFLEN = 1024*1024; // in bytes
//const int ABUFLEN = 1024; // in words //const int ABUFLEN = 1024; // in words
@ -72,6 +73,12 @@ const int BUFLEN = 1024*1024; // in bytes
// Yes this is ugly. :P // Yes this is ugly. :P
bool failure = false; bool failure = false;
#ifdef SHOWALL
bool showall = true;
#else
bool showall = false;
#endif
struct sockin { struct sockin {
int listener_fd, data_fd; int listener_fd, data_fd;
struct sockaddr_in serv_addr, cli_addr; struct sockaddr_in serv_addr, cli_addr;
@ -149,6 +156,8 @@ struct audio_sockin : public sockin {
const int IBUFLEN = 2048*1024; // in bytes const int IBUFLEN = 2048*1024; // in bytes
bool displayed = false;
struct image_sockin : public sockin { struct image_sockin : public sockin {
uint8_t buf[IBUFLEN]; uint8_t buf[IBUFLEN];
int bufsize; int bufsize;
@ -158,16 +167,16 @@ struct image_sockin : public sockin {
} }
void showImage(int begin, int end, int listener) { 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 imgbuf = cv::Mat(480, 640, CV_8U, &buf[begin]);
Mat imgMat = cv::imdecode(imgbuf, CV_LOAD_IMAGE_COLOR); Mat imgMat = cv::imdecode(imgbuf, CV_LOAD_IMAGE_COLOR);
if (!imgMat.data) cerr << "reading failed\r\n"; if (!imgMat.data) cerr << "reading failed\r\n";
// cerr << "x " << imgMat.rows << ' ' << imgMat.cols << "\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"; // 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() { virtual void newconn() {
@ -273,7 +279,14 @@ int main(void)
if (have_fd3) cerr << "Have video output socket\n"; if (have_fd3) cerr << "Have video output socket\n";
#endif #endif
// namedWindow("Display Window", WINDOW_AUTOSIZE ); // 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 // catch signals
if (((void *)signal(SIGINT,sigcatch) < 0) || 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++) { for (int i = 0; (rv > 0) && (i < num_sockets); i++) {
if (!s[i]) break; if (!s[i]) break;
@ -408,6 +422,7 @@ int main(void)
} }
} }
} }
if (displayed) waitKey(1);
}; };

2
external/happycube vendored

@ -1 +1 @@
Subproject commit 7918f6c2650811d0254f8a541634e999cb674daa Subproject commit 7acccfe272023de74864b1a83eee9ddbac9b8fd4