mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Minor fix
This commit is contained in:
@ -413,6 +413,7 @@ public:
|
|||||||
//"Content-Type: multipart/x-mixed-replace; boundary=boundary\r\n"
|
//"Content-Type: multipart/x-mixed-replace; boundary=boundary\r\n"
|
||||||
"\r\n", 0);
|
"\r\n", 0);
|
||||||
_write(client, "[\n", 0); // open JSON array
|
_write(client, "[\n", 0); // open JSON array
|
||||||
|
int n = _write(client, outputbuf, outlen);
|
||||||
cerr << "JSON_sender: new client " << client << endl;
|
cerr << "JSON_sender: new client " << client << endl;
|
||||||
}
|
}
|
||||||
else // existing client, just stream pix
|
else // existing client, just stream pix
|
||||||
@ -424,6 +425,7 @@ public:
|
|||||||
//sprintf(head, "\r\nContent-Length: %zu\r\n\r\n", outlen);
|
//sprintf(head, "\r\nContent-Length: %zu\r\n\r\n", outlen);
|
||||||
//sprintf(head, "--boundary\r\nContent-Type: application/json\r\nContent-Length: %zu\r\n\r\n", outlen);
|
//sprintf(head, "--boundary\r\nContent-Type: application/json\r\nContent-Length: %zu\r\n\r\n", outlen);
|
||||||
//_write(s, head, 0);
|
//_write(s, head, 0);
|
||||||
|
if(!close_all_sockets) _write(s, ", \n", 0);
|
||||||
int n = _write(s, outputbuf, outlen);
|
int n = _write(s, outputbuf, outlen);
|
||||||
if (n < outlen)
|
if (n < outlen)
|
||||||
{
|
{
|
||||||
@ -451,9 +453,7 @@ public:
|
|||||||
void send_json(detection *dets, int nboxes, int classes, char **names, long long int frame_id, int port, int timeout)
|
void send_json(detection *dets, int nboxes, int classes, char **names, long long int frame_id, int port, int timeout)
|
||||||
{
|
{
|
||||||
static JSON_sender js(port, timeout);
|
static JSON_sender js(port, timeout);
|
||||||
static char *send_buf = NULL;
|
char *send_buf = detection_to_json(dets, nboxes, classes, names, frame_id, NULL);
|
||||||
if (send_buf) js.write(", \n");
|
|
||||||
send_buf = detection_to_json(dets, nboxes, classes, names, frame_id, NULL);
|
|
||||||
|
|
||||||
js.write(send_buf);
|
js.write(send_buf);
|
||||||
std::cout << " JSON-stream sent. \n";
|
std::cout << " JSON-stream sent. \n";
|
||||||
|
@ -692,7 +692,7 @@ char *detection_to_json(detection *dets, int nboxes, int classes, char **names,
|
|||||||
//sprintf(buf, "{\"image_id\":%d, \"category_id\":%d, \"bbox\":[%f, %f, %f, %f], \"score\":%f}",
|
//sprintf(buf, "{\"image_id\":%d, \"category_id\":%d, \"bbox\":[%f, %f, %f, %f], \"score\":%f}",
|
||||||
// image_id, j, dets[i].bbox.x, dets[i].bbox.y, dets[i].bbox.w, dets[i].bbox.h, dets[i].prob[j]);
|
// image_id, j, dets[i].bbox.x, dets[i].bbox.y, dets[i].bbox.w, dets[i].bbox.h, dets[i].prob[j]);
|
||||||
|
|
||||||
sprintf(buf, " {\"class_id\":%d, \"name\":\"%s\", \"relative coordinates\":{\"center_x\":%f, \"center_y\":%f, \"width\":%f, \"height\":%f}, \"confidence\":%f}",
|
sprintf(buf, " {\"class_id\":%d, \"name\":\"%s\", \"relative_coordinates\":{\"center_x\":%f, \"center_y\":%f, \"width\":%f, \"height\":%f}, \"confidence\":%f}",
|
||||||
j, names[j], dets[i].bbox.x, dets[i].bbox.y, dets[i].bbox.w, dets[i].bbox.h, dets[i].prob[j]);
|
j, names[j], dets[i].bbox.x, dets[i].bbox.y, dets[i].bbox.w, dets[i].bbox.h, dets[i].prob[j]);
|
||||||
|
|
||||||
int send_buf_len = strlen(send_buf);
|
int send_buf_len = strlen(send_buf);
|
||||||
|
Reference in New Issue
Block a user