23#include <linux/videodev2.h>
117 { itsIMU = addSubComponent<jevois::ICM20948>(
"imu"); }
136 memcpy(outimg.
pixelsw<
void>(), inimg.
pixels<
void>(), std::min(inimg.
buf->length(), outimg.
buf->length()));
145 jevois::sformat(
"Accel: x=%+06.2fg y=%+06.2fg z=%+06.2fg Magn: %+09.2fuT %+09.2fuT %+09.2fuT",
150 jevois::sformat(
"Gyro: x=%+07.1fdps y=%+07.1fdps z=%+07.1fdps Temp: %05.1fC %s",
154 itsIMUdata.push_front(d);
157 while (itsIMU->dataReady() > 32) itsIMUdata.push_front(itsIMU->get());
160 while (itsIMUdata.size() > w/2) itsIMUdata.pop_back();
163 float const hh =
h * 0.5F;
int x = w - 1;
165 float const a = -afac::get();
float const g = -gfac::get();
float const m = -mfac::get();
209 unsigned short winw, winh;
213 int x = 0, y = 0;
unsigned short iw = 0, ih = 0;
215 helper.
itext(
"JeVois-Pro Inertial Measurement Unit (IMU)");
225 "Magn: %+09.2fuT %+09.2fuT %+09.2fuT",
231 itsIMUdata.push_front(d);
234 while (itsIMU->dataReady() > 32) itsIMUdata.push_front(itsIMU->get());
237 int const count = 300;
238 while (itsIMUdata.size() > count) itsIMUdata.pop_back();
240 float ax[count] = {}, ay[count] = {}, az[count] = {};
241 float gx[count] = {}, gy[count] = {}, gz[count] = {};
242 float mx[count] = {}, my[count] = {}, mz[count] = {};
245 float const a = -afac::get();
float const g = -gfac::get();
float const m = -mfac::get();
249 if (a) { ax[i] = dd.ax() * a; ay[i] = dd.ay() * a; az[i] = dd.az() * a; }
250 if (g) { gx[i] = dd.gx() * g; gy[i] = dd.gy() * g; gz[i] = dd.gz() * g; }
251 if (m) { mx[i] = dd.mx() * m; my[i] = dd.my() * m; mz[i] = dd.mz() * m; }
256 if (ImGui::Begin(
"IMU data"))
258 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - 10.0F);
259 ImGui::Text(
"Acceleration X, Y, Z:");
260 ImGui::PlotLines(
"##AccelX", ax, count, 0,
"Accel X", -100, 100);
261 ImGui::PlotLines(
"##AccelY", ay, count, 0,
"Accel Y", -100, 100);
262 ImGui::PlotLines(
"##AccelZ", az, count, 0,
"Accel Z", -100, 100);
264 ImGui::Text(
"Gyroscope X, Y, Z:");
265 ImGui::PlotLines(
"##GyroX", gx, count, 0,
"Gyro X", -100, 100);
266 ImGui::PlotLines(
"##GyroY", gy, count, 0,
"Gyro Y", -100, 100);
267 ImGui::PlotLines(
"##GyroZ", gz, count, 0,
"Gyro Z", -100, 100);
269 ImGui::Text(
"Magnetometer X, Y, Z:");
270 ImGui::PlotLines(
"##MagnX", mx, count, 0,
"Magn X", -100, 100);
271 ImGui::PlotLines(
"##MagnY", my, count, 0,
"Magn Y", -100, 100);
272 ImGui::PlotLines(
"##MagnZ", mz, count, 0,
"Magn Z", -100, 100);
273 ImGui::PopItemWidth();
278 std::string
const & fpscpu = timer.
stop();
279 helper.
iinfo(inframe, fpscpu, winw, winh);
287 std::shared_ptr<jevois::ICM20948> itsIMU;
288 std::list<jevois::IMUdata> itsIMUdata;
JEVOIS_REGISTER_MODULE(ArUcoBlob)
Plot raw IMU readings on top of video.
virtual ~DemoIMU()
Virtual destructor for safe inheritance.
JEVOIS_DECLARE_PARAMETER(gfac, float, "Factor applied to gyroscope values for display, or 0 to not display", 0.5F, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(mfac, float, "Factor applied to magnetometer values for display, or 0 to not display", 3.0F, ParamCateg)
Parameter.
DemoIMU(std::string const &instance)
Constructor.
JEVOIS_DECLARE_PARAMETER(afac, float, "Factor applied to acceleration values for display, or 0 to not display", 100.0F, ParamCateg)
Parameter.
virtual void process(jevois::InputFrame &&inframe, jevois::GUIhelper &helper) override
Processing function with GUI output.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function.
friend friend class Module
void drawInputFrame(char const *name, InputFrame const &frame, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool casync=false)
bool startFrame(unsigned short &w, unsigned short &h)
void iinfo(jevois::InputFrame const &inframe, std::string const &fpscpu, unsigned short winw=0, unsigned short winh=0)
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
std::shared_ptr< VideoBuf > buf
std::string const & stop(double *seconds)
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
void drawFilledRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int col)
void drawLine(RawImage &img, int x1, int y1, int x2, int y2, unsigned int thick, unsigned int col)
std::string sformat(char const *fmt,...) __attribute__((format(__printf__
unsigned short constexpr Black
unsigned short constexpr LightPink
unsigned short constexpr White
unsigned short constexpr DarkTeal
unsigned short constexpr LightTeal
unsigned short constexpr MedGreen
unsigned short constexpr DarkPink
unsigned short constexpr DarkGreen
unsigned short constexpr LightGreen
unsigned short constexpr MedPink
unsigned short constexpr MedTeal