Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lysonar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
isac .
lysonar
Commits
481b8cf0
Commit
481b8cf0
authored
9 months ago
by
Irreq
Browse files
Options
Downloads
Patches
Plain Diff
Documented main
parent
087b49de
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/beamformer.cpp
+66
-8
66 additions, 8 deletions
src/beamformer.cpp
with
66 additions
and
8 deletions
src/beamformer.cpp
+
66
−
8
View file @
481b8cf0
#include
"antenna.h"
#include
"config.h"
#include
"antenna.h"
#include
"delay.h"
#include
"pipeline.h"
#include
"ring_buffer.h"
#if AUDIO
#include
"RtAudio.h"
#include
"config.h"
#endif
#include
<Eigen/Dense>
#include
<cmath>
#include
<cstdlib>
...
...
@@ -15,15 +20,23 @@
#include
<opencv2/opencv.hpp>
#include
<signal.h>
#include
<thread>
// using namespace std;
using
namespace
Eigen
;
using
namespace
cv
;
#define CAMERA 1
#define VALID_SENSOR(i) ((128 <= i) && (128 + 64 > i))
bool
canPlot
=
false
;
/**
* @brief Calculate delays for different angles beforehand
*
* @param flat_delays delays to use
* @param antenna antenna structure
* @param fov field of view
* @param resolution_x width resolution
* @param resolution_y height resolution
*/
void
compute_scanning_window
(
float
*
flat_delays
,
const
Antenna
&
antenna
,
float
fov
,
int
resolution_x
,
int
resolution_y
)
{
...
...
@@ -90,6 +103,15 @@ void compute_scanning_window2(float *flat_delays, const Antenna &antenna,
// return delays;
}
/**
* @brief Convert multiple input streams into single level by delay
*
* @param t_id [TODO:parameter]
* @param task pool partition
* @param flat_delays delays to use
* @param rb ring buffer to use
* @return power level
*/
float
miso
(
int
t_id
,
int
task
,
float
*
flat_delays
,
ring_buffer
&
rb
)
{
float
out
[
N_SAMPLES
]
=
{
0.0
};
for
(
int
s
=
0
;
s
<
N_SENSORS
;
s
++
)
{
...
...
@@ -117,10 +139,22 @@ float miso(int t_id, int task, float *flat_delays, ring_buffer &rb) {
}
Mat
noiseMatrix
(
Y_RES
,
X_RES
,
CV_8UC1
);
// If Audio playback when streaming
#if AUDIO
RtAudio
audio
;
int
play
=
1
;
std
::
thread
*
producer
;
std
::
vector
<
float
>
audioBuffer
(
N_SAMPLES
*
2
,
0.0
);
/**
* @brief Producer for audio on pipeline
*
* @param pipeline Pipeline
*/
void
audio_producer
(
Pipeline
&
pipeline
)
{
ring_buffer
&
rb
=
pipeline
.
getRingBuffer
();
...
...
@@ -163,6 +197,17 @@ void audio_producer(Pipeline &pipeline) {
}
}
/**
* @brief Callback for audio stream
*
* @param outputBuffer Speaker buffer
* @param inputBuffer empty (Required by RtAudio API)
* @param nBufferFrames number of frames to fill
* @param streamTime duration
* @param status status
* @param userData the incoming data
* @return OK
*/
int
audioCallback
(
void
*
outputBuffer
,
void
*
inputBuffer
,
unsigned
int
nBufferFrames
,
double
streamTime
,
RtAudioStreamStatus
status
,
void
*
userData
)
{
...
...
@@ -173,7 +218,7 @@ int audioCallback(void *outputBuffer, void *inputBuffer,
if
(
!
play
)
{
*
buffer
++
=
audioBuffer
[
i
];
}
else
{
cout
<<
"U
N
derflow"
<<
endl
;
cout
<<
"U
n
derflow"
<<
endl
;
*
buffer
++
=
0.0
;
}
}
...
...
@@ -183,6 +228,12 @@ int audioCallback(void *outputBuffer, void *inputBuffer,
return
0
;
}
/**
* @brief Initiate Audio player for Pipeline
*
* @param pipeline the pipeline to follow
* @return status
*/
int
init_audio_playback
(
Pipeline
&
pipeline
)
{
if
(
audio
.
getDeviceCount
()
<
1
)
{
std
::
cout
<<
"No audio devices found!"
<<
std
::
endl
;
...
...
@@ -222,6 +273,8 @@ void stop_audio_playback() {
audio
.
closeStream
();
}
#endif
void
naive_seeker
(
Pipeline
&
pipeline
)
{
Antenna
antenna
=
create_antenna
(
Position
(
0
,
0
,
0
),
COLUMNS
,
ROWS
,
DISTANCE
);
...
...
@@ -429,7 +482,9 @@ int main() {
noiseMatrix
.
setTo
(
Scalar
(
0
));
// init_audio_playback(pipeline);
#if AUDIO
init_audio_playback
(
pipeline
);
#endif
#if CAMERA
cv
::
VideoCapture
cap
(
CAMERA_PATH
);
// Open the default camera (change the
...
...
@@ -523,7 +578,10 @@ int main() {
//
pipeline
.
disconnect
();
// stop_audio_playback();
#if AUDIO
stop_audio_playback
();
#endif
destroyAllWindows
();
//
worker.join();
worker
.
join
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment