53 #ifndef VIEWVIDEO_DOWNSIZE_FACTOR
54 #define VIEWVIDEO_DOWNSIZE_FACTOR 4
59 #ifndef VIEWVIDEO_QUALITY_FACTOR
60 #define VIEWVIDEO_QUALITY_FACTOR 50
65 #ifndef VIEWVIDEO_RTP_TIME_INC
66 #define VIEWVIDEO_RTP_TIME_INC 0
71 #ifndef VIEWVIDEO_SHOT_PATH
72 #ifdef VIDEO_THREAD_SHOT_PATH
73 #define VIEWVIDEO_SHOT_PATH VIDEO_THREAD_SHOT_PATH
75 #define VIEWVIDEO_SHOT_PATH /data/video/images
82 #define VIEWVIDEO_FPS 10
87 #ifndef VIEWVIDEO_NICE_LEVEL
88 #define VIEWVIDEO_NICE_LEVEL 5
93 #ifndef VIEWVIDEO_USE_NETCAT
94 #define VIEWVIDEO_USE_NETCAT FALSE
97 #if !VIEWVIDEO_USE_NETCAT && !(defined VIEWVIDEO_USE_RTP)
98 #define VIEWVIDEO_USE_RTP TRUE
101 #if VIEWVIDEO_USE_NETCAT
102 #include <sys/wait.h>
111 PRINT_CONFIG_VAR(VIEWVIDEO_HOST)
112 PRINT_CONFIG_VAR(VIEWVIDEO_PORT_OUT)
119 #if !VIEWVIDEO_USE_NETCAT
142 #if VIEWVIDEO_USE_NETCAT
144 sprintf(nc_cmd,
"nc %s %d 2>/dev/null", STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT);
157 #if VIEWVIDEO_USE_NETCAT
162 printf(
"[viewvideo] Could not create netcat fork.\n");
163 }
else if (pid == 0) {
165 FILE *netcat = popen(nc_cmd,
"w");
166 if (netcat != NULL) {
170 printf(
"[viewvideo] Failed to open netcat process.\n");
222 #if VIEWVIDEO_USE_NETCAT
225 FILE *fp = fopen(save_name,
"w");
227 fprintf(fp,
"i=0\n");
228 fprintf(fp,
"while true\n");
230 fprintf(fp,
"\tn=$(printf \"%%04d\" $i)\n");
231 fprintf(fp,
"\tnc -l 0.0.0.0 %d > img_${n}.jpg\n", (
int)(VIEWVIDEO_PORT_OUT));
232 fprintf(fp,
"\ti=$((i+1))\n");
233 fprintf(fp,
"done\n");
236 printf(
"[viewvideo] Failed to create netcat receiver file.\n");
244 FILE *fp = fopen(save_name,
"w");
246 fprintf(fp,
"v=0\n");
247 fprintf(fp,
"m=video %d RTP/AVP 26\n", (
int)(VIEWVIDEO_PORT_OUT));
248 fprintf(fp,
"c=IN IP4 0.0.0.0\n");
251 printf(
"[viewvideo] Failed to create SDP file.\n");
struct video_listener * cv_add_to_device_async(struct video_config_t *device, cv_function func, int nice_level)
uint32_t buf_size
The buffer size.
struct viewvideo_t viewvideo
bool use_rtp
Stream over RTP.
void image_yuv422_downsample(struct image_t *input, struct image_t *output, uint16_t downsample)
Simplified high-speed low CPU downsample function without averaging downsample factor must be 1...
#define VIEWVIDEO_RTP_TIME_INC
#define VIEWVIDEO_QUALITY_FACTOR
#define VIEWVIDEO_DOWNSIZE_FACTOR
void image_free(struct image_t *img)
Free the image.
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Easily create and use UDP sockets.
#define VIEWVIDEO_SHOT_PATH
#define VIEWVIDEO_USE_NETCAT
void rtp_frame_send(struct UdpSocket *udp, struct image_t *img, uint8_t format_code, uint8_t quality_code, uint8_t has_dri_header, uint32_t delta_t)
Send an RTP frame.
struct video_listener * listener
Image helper functions like resizing, color filter, converters...
Computer vision framework for onboard processing.
struct UdpSocket video_sock
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void * buf
Image buffer (depending on the image_type)
volatile bool is_streaming
When the device is streaming.
#define VIEWVIDEO_USE_RTP
#define VIEWVIDEO_NICE_LEVEL
Encode images with the use of the JPEG encoding.
void viewvideo_init(void)
Initialize the view video.
Get live images from a RTP/UDP stream and save pictures on internal memory.
void jpeg_encode_image(struct image_t *in, struct image_t *out, uint32_t quality_factor, bool add_dri_header)
Encode an YUV422 image.
UYVY format (uint16 per pixel)
uint8_t downsize_factor
Downsize factor during the stream.
Encodes a vide stream with RTP (JPEG)
struct image_t * viewvideo_function(struct image_t *img)
Handles all the video streaming and saving of the image shots This is a sepereate thread...
int udp_socket_create(struct UdpSocket *sock, char *host, int port_out, int port_in, bool broadcast)
Create UDP socket and bind it.
An JPEG encoded image (not per pixel encoded)