mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
[modules] added edge_flow files to be inserted in the optical flow module
This commit is contained in:
@@ -82,7 +82,26 @@
|
|||||||
<!-- Main vision calculations -->
|
<!-- Main vision calculations -->
|
||||||
<file name="fast_rosten.c" dir="modules/computer_vision/lib/vision"/>
|
<file name="fast_rosten.c" dir="modules/computer_vision/lib/vision"/>
|
||||||
<file name="lucas_kanade.c" dir="modules/computer_vision/lib/vision"/>
|
<file name="lucas_kanade.c" dir="modules/computer_vision/lib/vision"/>
|
||||||
|
<file name="edge_flow.c" dir="modules/computer_vision/lib/vision"/>
|
||||||
|
<raw>
|
||||||
|
include $(CFG_SHARED)/udp.makefile
|
||||||
|
|
||||||
|
VIEWVIDEO_HOST ?= $(MODEM_HOST)
|
||||||
|
VIEWVIDEO_PORT_OUT ?= 5000
|
||||||
|
VIEWVIDEO_BROADCAST ?= TRUE
|
||||||
|
VIEWVIDEO_USE_NETCAT ?= FALSE
|
||||||
|
|
||||||
|
VIEWVID_CFLAGS = -DVIEWVIDEO_HOST=$(VIEWVIDEO_HOST) -DVIEWVIDEO_PORT_OUT=$(VIEWVIDEO_PORT_OUT)
|
||||||
|
ifneq (,$(findstring $(VIEWVIDEO_USE_NETCAT),0 FALSE))
|
||||||
|
ap.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=$(VIEWVIDEO_BROADCAST)
|
||||||
|
nps.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=FALSE
|
||||||
|
else
|
||||||
|
$(TARGET).CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NETCAT
|
||||||
|
endif
|
||||||
|
</raw>
|
||||||
|
|
||||||
</makefile>
|
</makefile>
|
||||||
|
|
||||||
|
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* edge_flow.c
|
||||||
|
*
|
||||||
|
* Created on: Feb 22, 2016
|
||||||
|
* Author: knmcguire
|
||||||
|
*/
|
||||||
|
#include <lib/vision/edge_flow.h>
|
||||||
|
|
||||||
|
|
||||||
|
void test_function(struct image_t *img,struct image_t *img_gray)
|
||||||
|
{
|
||||||
|
image_to_grayscale(img, img_gray);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* edge_flow.h
|
||||||
|
*
|
||||||
|
* Created on: Feb 22, 2016
|
||||||
|
* Author: knmcguire
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EDGE_FLOW_H_
|
||||||
|
#define EDGE_FLOW_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "std.h"
|
||||||
|
#include "opticflow/inter_thread_data.h"
|
||||||
|
#include "lib/vision/image.h"
|
||||||
|
#include "lib/v4l/v4l2.h"
|
||||||
|
|
||||||
|
void test_function(struct image_t *image,struct image_t *image_gray);
|
||||||
|
|
||||||
|
#endif /* EDGE_FLOW_H_ */
|
||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "lib/v4l/v4l2.h"
|
#include "lib/v4l/v4l2.h"
|
||||||
#include "lib/encoding/jpeg.h"
|
#include "lib/encoding/jpeg.h"
|
||||||
#include "lib/encoding/rtp.h"
|
#include "lib/encoding/rtp.h"
|
||||||
|
#include "lib/vision/edge_flow.h"
|
||||||
|
|
||||||
|
|
||||||
/* Default sonar/agl to use in opticflow visual_estimator */
|
/* Default sonar/agl to use in opticflow visual_estimator */
|
||||||
#ifndef OPTICFLOW_AGL_ID
|
#ifndef OPTICFLOW_AGL_ID
|
||||||
@@ -77,6 +79,8 @@ static pthread_t opticflow_calc_thread; ///< The optical flow calcula
|
|||||||
static bool_t opticflow_got_result; ///< When we have an optical flow calculation
|
static bool_t opticflow_got_result; ///< When we have an optical flow calculation
|
||||||
static pthread_mutex_t opticflow_mutex; ///< Mutex lock fo thread safety
|
static pthread_mutex_t opticflow_mutex; ///< Mutex lock fo thread safety
|
||||||
|
|
||||||
|
struct UdpSocket video_sock;
|
||||||
|
|
||||||
/* Static functions */
|
/* Static functions */
|
||||||
static void *opticflow_module_calc(void *data); ///< The main optical flow calculation thread
|
static void *opticflow_module_calc(void *data); ///< The main optical flow calculation thread
|
||||||
static void opticflow_agl_cb(uint8_t sender_id, float distance); ///< Callback function of the ground altitude
|
static void opticflow_agl_cb(uint8_t sender_id, float distance); ///< Callback function of the ground altitude
|
||||||
@@ -140,6 +144,12 @@ void opticflow_module_init(void)
|
|||||||
#if PERIODIC_TELEMETRY
|
#if PERIODIC_TELEMETRY
|
||||||
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_OPTIC_FLOW_EST, opticflow_telem_send);
|
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_OPTIC_FLOW_EST, opticflow_telem_send);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OPTICFLOW_DEBUG
|
||||||
|
|
||||||
|
udp_socket_create(&video_sock, STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT, -1, VIEWVIDEO_BROADCAST);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,9 +234,14 @@ static void *opticflow_module_calc(void *data __attribute__((unused)))
|
|||||||
#if OPTICFLOW_DEBUG
|
#if OPTICFLOW_DEBUG
|
||||||
// Create a new JPEG image
|
// Create a new JPEG image
|
||||||
struct image_t img_jpeg;
|
struct image_t img_jpeg;
|
||||||
|
|
||||||
image_create(&img_jpeg, opticflow_dev->w, opticflow_dev->h, IMAGE_JPEG);
|
image_create(&img_jpeg, opticflow_dev->w, opticflow_dev->h, IMAGE_JPEG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct image_t img_gray;
|
||||||
|
image_create(&img_gray, opticflow_dev->w, opticflow_dev->h, IMAGE_YUV422);
|
||||||
|
|
||||||
|
|
||||||
/* Main loop of the optical flow calculation */
|
/* Main loop of the optical flow calculation */
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
// Try to fetch an image
|
// Try to fetch an image
|
||||||
@@ -243,6 +258,9 @@ static void *opticflow_module_calc(void *data __attribute__((unused)))
|
|||||||
struct opticflow_result_t temp_result;
|
struct opticflow_result_t temp_result;
|
||||||
opticflow_calc_frame(&opticflow, &temp_state, &img, &temp_result);
|
opticflow_calc_frame(&opticflow, &temp_state, &img, &temp_result);
|
||||||
|
|
||||||
|
test_function(&img,&img_gray);
|
||||||
|
//image_to_grayscale(&img, &img_gray);
|
||||||
|
|
||||||
// Copy the result if finished
|
// Copy the result if finished
|
||||||
pthread_mutex_lock(&opticflow_mutex);
|
pthread_mutex_lock(&opticflow_mutex);
|
||||||
memcpy(&opticflow_result, &temp_result, sizeof(struct opticflow_result_t));
|
memcpy(&opticflow_result, &temp_result, sizeof(struct opticflow_result_t));
|
||||||
@@ -250,9 +268,9 @@ static void *opticflow_module_calc(void *data __attribute__((unused)))
|
|||||||
pthread_mutex_unlock(&opticflow_mutex);
|
pthread_mutex_unlock(&opticflow_mutex);
|
||||||
|
|
||||||
#if OPTICFLOW_DEBUG
|
#if OPTICFLOW_DEBUG
|
||||||
jpeg_encode_image(&img, &img_jpeg, 70, FALSE);
|
jpeg_encode_image(&img_gray, &img_jpeg, 70, FALSE);
|
||||||
rtp_frame_send(
|
rtp_frame_send(
|
||||||
&VIEWVIDEO_DEV, // UDP device
|
&video_sock, // UDP device
|
||||||
&img_jpeg,
|
&img_jpeg,
|
||||||
0, // Format 422
|
0, // Format 422
|
||||||
70, // Jpeg-Quality
|
70, // Jpeg-Quality
|
||||||
@@ -267,6 +285,7 @@ static void *opticflow_module_calc(void *data __attribute__((unused)))
|
|||||||
|
|
||||||
#if OPTICFLOW_DEBUG
|
#if OPTICFLOW_DEBUG
|
||||||
image_free(&img_jpeg);
|
image_free(&img_jpeg);
|
||||||
|
image_free(&img_gray);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user