Skip to content
Snippets Groups Projects
Verified Commit c256b0c1 authored by Qiyang Sun's avatar Qiyang Sun :speech_balloon:
Browse files

Add OpenCV libraries and sample C++ vision program

build tools is Autotools
parent ee3db815
Branches
Tags
No related merge requests found
...@@ -14,6 +14,19 @@ IMAGE_INSTALL = "packagegroup-core-boot \ ...@@ -14,6 +14,19 @@ IMAGE_INSTALL = "packagegroup-core-boot \
libv4l \ libv4l \
media-ctl \ media-ctl \
opencv \ opencv \
opencv-dev \
libopencv-aruco \
libopencv-aruco-dev \
libopencv-core \
libopencv-core-dev \
libopencv-imgcodecs \
libopencv-imgcodecs-dev \
libopencv-imgproc \
libopencv-imgproc-dev \
libopencv-video \
libopencv-video-dev \
libopencv-videoio \
libopencv-videoio-dev \
ffmpeg \ ffmpeg \
libcamera \ libcamera \
libcamera-dev \ libcamera-dev \
...@@ -24,6 +37,7 @@ IMAGE_INSTALL = "packagegroup-core-boot \ ...@@ -24,6 +37,7 @@ IMAGE_INSTALL = "packagegroup-core-boot \
gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \ gstreamer1.0-plugins-ugly \
gstreamer1.0-plugins-good-rpicamsrc \ gstreamer1.0-plugins-good-rpicamsrc \
visionhellocc \
${CORE_IMAGE_EXTRA_INSTALL}" ${CORE_IMAGE_EXTRA_INSTALL}"
COMPATIBLE_MACHINE = "^rpi$" COMPATIBLE_MACHINE = "^rpi$"
......
Makefile.in
/ar-lib
/mdate-sh
/py-compile
/test-driver
/ylwrap
.deps/
.dirstamp
autom4te.cache
/autoscan.log
/autoscan-*.log
/aclocal.m4
/compile
/config.cache
/config.guess
/config.h.in
/config.log
/config.status
/config.sub
/configure
/configure.scan
/depcomp
/install-sh
/missing
/stamp-h1
/ltmain.sh
/texinfo.tex
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
Makefile
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache/
/config.*
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/m4/
/missing
/stamp-h?
.deps/
.dirstamp
.libs/
*.l[ao]
*~
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache/
/config.*
/configure
/m4/
/stamp-h?
.deps/
.dirstamp
*.o
*~
This diff is collapsed.
AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = src
EXTRA_DIST = COPYING
=============
VISIONHELLOCC
=============
The hello world program for OpenCV written in C++
This program is part of meta-marfb layer -- The MAR fastboot
Linux. Licensed under GNU GPL-3.0-or-later.
This program is part of the MAR24 project.
-------------
GNU AUTOTOOLS
-------------
To use Autotools to build, first source the SDK or eSDK
environment. Then, run the following commands to cross-compile.
$ autoreconf
$ ./configure --host=arm-oe-linux-gnueabi
$ make
To install to ./tmp on host, run:
$ make install DESTDIR=./tmp
To prepare tarball for bitbake, run:
$ make dist
Refer to GNU Autotools Manual for Autotools usage.
AC_INIT([visionhellocc],[1.0],[qs2g22@soton.ac.uk])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CXX
AC_PROG_CC
PKG_CHECK_MODULES([OPENCV], [opencv4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
bin_PROGRAMS = visionhellocc
visionhellocc_SOURCES = main.cc
visionhellocc_CPPFLAGS = $(OPENCV_CFLAGS)
visionhellocc_LDADD = $(OPENCV_LIBS)
// SPDX-License-Identifier: GPL-3.0-or-later
#include <opencv2/opencv.hpp>
#include <iostream>
int
main(void) {
cv::VideoCapture cap("libcamerasrc ! "
"video/x-raw,framerate=50/1,width=640,height=480 !"
"videoscale ! videoconvert ! appsink",
cv::CAP_GSTREAMER);
if (!cap.isOpened()) {
std::cerr << "Error: Could not open video stream." << std::endl;
return -1;
}
int frame_width = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_WIDTH));
int frame_height = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_HEIGHT));
cv::Size size(frame_width, frame_height);
std::cout << "Frame size: " << size << std::endl;
cv::VideoWriter result("file.avi",
cv::VideoWriter::fourcc('M','J','P','G'),
10,
size);
if (!result.isOpened()) {
std::cerr << "Error: Could not open the output video file." << std::endl;
return -1;
}
for (int x = 0; x < 50; ++x) {
cv::Mat frame;
bool ret = cap.read(frame);
if (!ret) {
std::cerr << "Error: Could not read frame." << std::endl;
break;
}
result.write(frame);
std::cout << "Captured frame " << x << std::endl;
}
std::cout << "Completed." << std::endl;
result.release();
cap.release();
return 0;
}
// Local Variables:
// indent-tabs-mode: t
// tab-width: 8
// eval: (set-frame-width (selected-frame) 90)
// eval: (elcord-mode 1)
// eval: (auto-revert-mode 1)
// End:
File added
SUMMARY = "Vision helloworld program with C++ and Autotools"
LICENSE = "GPL-3.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=1c76c4cc354acaac30ed4d5eefea7245"
DEPENDS = " opencv \
ffmpeg \
libcamera \
gstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
"
PV = "1.0"
SRC_URI = "file://visionhellocc-${PV}.tar.gz"
S = "${WORKDIR}/${BP}"
FILES:${PN} = "/usr/bin/visionhellocc"
inherit autotools pkgconfig
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment