summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMinori Yasumura <minori@witz-inc.co.jp>2019-09-05 09:31:48 +0900
committerMinori Yasumura <minori@witz-inc.co.jp>2019-09-11 10:07:21 +0900
commit6e1a6785dd4658939d9380a6c2b092a495009e17 (patch)
tree49cbb889392a24859afa1bb5a405d5f0f0024b4c /app
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
Aroundview application is a sample application. It's a simple application that takes into the camera input and draws them like all around view using v4l2 technology. Signed-off-by: Minori Yasumura <minori@witz-inc.co.jp> Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@denso-ten.com> Change-Id: I3e59b728a8bb7f197d666b56e7f86f02ddc8ea98
Diffstat (limited to 'app')
-rw-r--r--app/AroundView.qml194
-rw-r--r--app/AroundView.qrc5
-rw-r--r--app/app.pri12
-rw-r--r--app/app.pro23
-rw-r--r--app/camera.cpp88
-rw-r--r--app/camera.h41
-rw-r--r--app/capturing.cpp404
-rw-r--r--app/capturing.h70
-rwxr-xr-xapp/config.tests/libhomescreen/libhomescreen.cpp8
-rwxr-xr-xapp/config.tests/libhomescreen/libhomescreen.pro5
-rw-r--r--app/images/HMI_Radiocontrol_Car.pngbin0 -> 752629 bytes
-rw-r--r--app/images/images.qrc7
-rw-r--r--app/images/triangle_back_full.pngbin0 -> 19236 bytes
-rw-r--r--app/images/triangle_front_full.pngbin0 -> 19136 bytes
-rw-r--r--app/main.cpp37
15 files changed, 894 insertions, 0 deletions
diff --git a/app/AroundView.qml b/app/AroundView.qml
new file mode 100644
index 0000000..1967610
--- /dev/null
+++ b/app/AroundView.qml
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import QtQuick 2.6
+import QtQuick.Controls 2.0
+import OpenCV 1.0
+import QtGraphicalEffects 1.0
+
+ApplicationWindow {
+ visible: true
+ width: 1280
+ height: 720
+ title: qsTr("around view!")
+
+
+ //Car image
+ Image {
+ id: car
+ anchors.centerIn: parent
+ source: './images/HMI_Radiocontrol_Car.png'
+ z: 3
+ }
+
+ //border
+ Rectangle {
+ width: 5
+ height: 1550
+ anchors.bottom: back_rec.bottom
+ anchors.bottomMargin:371
+ visible: true
+ color: "blue"
+
+ transformOrigin: Rectangle.BottomLeft
+ rotation: 45
+
+ z: 2
+ }
+ Rectangle {
+ width: 5
+ height: 1550
+ anchors.right: parent.right
+ anchors.bottom: back_rec.bottom
+ anchors.bottomMargin:371
+ visible: true
+ color: "blue"
+
+ transformOrigin: Rectangle.BottomLeft
+ rotation: -45
+ z: 2
+ }
+
+ //front
+ Rectangle {
+ id: front_rec
+ width: 1080
+ height: 910
+ anchors.bottom: car.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ visible: false
+
+ Camera1 {
+ id: camera1
+ property int ret: 0
+ anchors.fill: parent
+ }
+ }
+
+ //mask
+ Image {
+ id:front_mask
+ source: "images/triangle_front_full.png"
+ sourceSize: Qt.size(1080, 540)
+ smooth: true
+ visible: false
+ }
+
+ OpacityMask {
+ anchors.fill: front_rec
+ source: front_rec
+ maskSource: front_mask
+ z: 1
+ }
+
+
+ //back
+ Rectangle {
+ id: back_rec
+ width: 1080
+ height: 910
+ anchors.top: car.verticalCenter
+ // anchors.topMargin : -100
+ anchors.horizontalCenter: parent.horizontalCenter
+ visible: false
+
+ Camera0 {
+ id: camera0
+ property int ret: 0
+ anchors.fill: parent
+ }
+ }
+
+ //mask
+ Image {
+ id:back_mask
+ source: "images/triangle_back_full.png"
+ sourceSize: Qt.size(back_rec.width, back_rec.height)
+ smooth: true
+ visible: false
+ }
+
+ OpacityMask {
+ anchors.fill: back_rec
+ source: back_rec
+ maskSource: back_mask
+ z: 1
+ }
+
+
+ //left
+ Rectangle {
+ id: left_rec
+ width: 1080
+ height: 540
+ anchors.top: parent.top
+ anchors.topMargin: (parent.height/2)+(width/2)
+ anchors.left: parent.left
+ transformOrigin: Rectangle.TopLeft
+ rotation: 270
+
+ visible: true
+
+ Camera2 {
+ id: camera2
+ property int ret: 0
+ anchors.fill: parent
+ }
+ }
+
+
+ //right
+ Rectangle {
+ id: right_rec
+ width: 1080
+ height: 540
+ anchors.top: parent.top
+ anchors.topMargin: (parent.height/2)+(width/2)
+ anchors.right: parent.right
+ transformOrigin: Rectangle.TopRight
+ rotation: 90
+
+ visible: true
+
+ Camera3 {
+ id: camera3
+ property int ret: 0
+ anchors.fill: parent
+ }
+ }
+
+ Timer {
+ id: timer
+ property int frameRate: 30
+ interval: 1000 / timer.frameRate
+ running: true
+ repeat: true
+
+ onTriggered: {
+ camera0.update();
+ camera1.update();
+ camera2.update();
+ camera3.update();
+ }
+ }
+
+ Component.onCompleted: {
+ camera0.ret=camera0.init(0,100)
+ camera1.ret=camera1.init(1,-100)
+ camera2.ret=camera2.init(2,0)
+ camera3.ret=camera3.init(3,0)
+ }
+}
diff --git a/app/AroundView.qrc b/app/AroundView.qrc
new file mode 100644
index 0000000..244cec5
--- /dev/null
+++ b/app/AroundView.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>AroundView.qml</file>
+ </qresource>
+</RCC> \ No newline at end of file
diff --git a/app/app.pri b/app/app.pri
new file mode 100644
index 0000000..ce5fb04
--- /dev/null
+++ b/app/app.pri
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+load(configure)
+qtCompileTest(libhomescreen)
+
+config_libhomescreen {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += homescreen
+ DEFINES += HAVE_LIBHOMESCREEN
+}
+
+DESTDIR = $${OUT_PWD}/../package/root/bin
diff --git a/app/app.pro b/app/app.pro
new file mode 100644
index 0000000..dcdb1aa
--- /dev/null
+++ b/app/app.pro
@@ -0,0 +1,23 @@
+TARGET = aroundview
+QT = quickcontrols2
+QT += widgets
+QT += quick gui aglextras
+
+
+SOURCES = main.cpp \
+ camera.cpp \
+ capturing.cpp \
+
+
+HEADERS += camera.h \
+ capturing.h \
+
+RESOURCES += AroundView.qrc\
+ images/images.qrc
+
+INCLUDEPATH += /usr/include/opencv2
+DEPENDPATH += /usr/include/opencv2
+
+LIBS += `pkg-config opencv --libs`
+
+include(app.pri)
diff --git a/app/camera.cpp b/app/camera.cpp
new file mode 100644
index 0000000..964cc8c
--- /dev/null
+++ b/app/camera.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "camera.h"
+#include "capturing.h"
+#include <QDebug>
+
+
+
+
+CameraItem::CameraItem(QQuickItem *parent)
+ : QQuickPaintedItem(parent), _device(-1), _offset(0)
+{
+}
+
+CameraItem::~CameraItem()
+{
+ if(_device != -1) {
+ p_cap_item->close_device();
+ }
+ if(p_cap_item)
+ delete p_cap_item;
+}
+
+
+int CameraItem::init(int device, int offset)
+{
+ p_cap_item = new CapturingItem();
+
+ int ret = p_cap_item->open_device(device);
+
+ if(ret != 0) {
+ qDebug() << "device " << device << " failed to open";
+ return -1;
+ }
+
+ ret = p_cap_item->init_device();
+ if(ret != 0) {
+ qDebug() << "device " << device << " failed to initialize";
+ return -1;
+ }
+ p_cap_item->start_capturing();
+ _device = device;
+ _offset = offset;
+
+ return ret;
+}
+
+void CameraItem::paint(QPainter *painter)
+{
+ if(_device != -1){
+ unsigned char* data = NULL;
+ cv::Mat src(p_cap_item->height(), p_cap_item->width(), CV_8UC4);
+ cv::Mat dst;
+ data = p_cap_item->snap_frame();
+ if(data) {
+ memcpy(src.data, data, src.step * src.rows);
+
+ cv::cvtColor(src, dst, CV_BGRA2RGB);
+
+ QImage output_img(dst.data, dst.cols, dst.rows, QImage::Format_RGB888);
+
+ output_img = output_img.scaled(1080, 911);
+
+ painter->drawImage(0,0,
+ output_img,
+ 0,((output_img.size().height() / 2) - (height() / 2) + _offset));
+ }
+ else {
+ qDebug() << "null image";
+ }
+ }
+
+}
+
diff --git a/app/camera.h b/app/camera.h
new file mode 100644
index 0000000..3b0d6cd
--- /dev/null
+++ b/app/camera.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CAMERA_H
+#define CAMERA_H
+#include <QtQuick/QQuickPaintedItem>
+#include <QPainter>
+#include <QImage>
+#include <opencv2/opencv.hpp>
+#include <QString>
+
+class CapturingItem;
+
+class CameraItem : public QQuickPaintedItem
+{
+ Q_OBJECT
+public:
+ CameraItem(QQuickItem *parent = 0);
+ ~CameraItem();
+ void paint(QPainter *painter);
+ Q_INVOKABLE int init(int device,int offset);
+
+private:
+ int _device;
+ int _offset;
+ CapturingItem *p_cap_item;
+};
+#endif
diff --git a/app/capturing.cpp b/app/capturing.cpp
new file mode 100644
index 0000000..fd2a6c5
--- /dev/null
+++ b/app/capturing.cpp
@@ -0,0 +1,404 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <string>
+#include <sstream>
+#include <getopt.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include <linux/videodev2.h>
+#include <linux/fb.h>
+
+#include <pthread.h>
+#include "capturing.h"
+
+#define CLEAR(x) memset(&(x), 0, sizeof(x))
+
+#define FIELD V4L2_FIELD_NONE
+
+using std::istringstream;
+
+CapturingItem::CapturingItem()
+ : _dev_name(""),
+ _fd(-1), _fps_count(0), _framerate(0), _timeout(60),
+ _left(0), _top(0), _width(1280), _height(1080)
+{
+}
+
+CapturingItem::~CapturingItem()
+{
+}
+
+int CapturingItem::open_device(int dev)
+{
+ struct stat st;
+ std::stringstream ss;
+ ss << "/dev/video";
+ ss << dev;
+ ss >> _dev_name;
+
+ if (-1 == stat(_dev_name.c_str(), &st)) {
+ fprintf(stderr, "Cannot identify '%s': %d, %s\n",
+ _dev_name.c_str(), errno, strerror(errno));
+ return -1;
+ }
+
+ if (!S_ISCHR(st.st_mode)) {
+ fprintf(stderr, "%s is no device\n", _dev_name.c_str());
+ return -1;
+ }
+
+ _fd = open(_dev_name.c_str(), O_RDWR /* Required */ | O_NONBLOCK, 0);
+
+ if (-1 == _fd) {
+ fprintf(stderr, "Cannot open '%s': %d, %s\n",
+ _dev_name.c_str(), errno, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+int CapturingItem::init_device(void)
+{
+ struct v4l2_capability cap;
+ struct v4l2_cropcap cropcap;
+ struct v4l2_crop crop;
+ struct v4l2_format fmt;
+
+ if (-1 == xioctl(_fd, VIDIOC_QUERYCAP, &cap)) {
+ if (EINVAL == errno) {
+ fprintf(stderr, "%s is no V4L2 device\n", _dev_name.c_str());
+ exit(EXIT_FAILURE);
+ } else {
+ errno_exit("VIDIOC_QUERYCAP");
+ }
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ fprintf(stderr, "%s is no video capture device\n", _dev_name.c_str());
+ exit(EXIT_FAILURE);
+ }
+
+
+ /* Select video input, video standard and adjust. */
+ CLEAR(cropcap);
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (0 == xioctl(_fd, VIDIOC_CROPCAP, &cropcap)) {
+ crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ crop.c = cropcap.defrect; /* reset to default */
+
+ crop.c.left = _left;
+ crop.c.top = _top;
+ crop.c.width = _width;
+ crop.c.height = _height;
+
+ if (-1 == xioctl(_fd, VIDIOC_S_CROP, &crop)) {
+ switch (errno) {
+ case EINVAL:
+ /* Trimming is not supported. */
+ break;
+ default:
+ /* The error is ignored. */
+ break;
+ }
+ }
+ } else {
+ /* The error is ignored. */
+ }
+
+ if (_framerate) {
+ struct v4l2_streamparm parm;
+
+ parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (-1 == xioctl(_fd, VIDIOC_G_PARM, &parm))
+ errno_exit("VIDIOC_G_PARM");
+
+ parm.parm.capture.timeperframe.numerator = 1;
+ parm.parm.capture.timeperframe.denominator = _framerate;
+ if (-1 == xioctl(_fd, VIDIOC_S_PARM, &parm))
+ errno_exit("VIDIOC_S_PARM");
+ }
+
+ CLEAR(fmt);
+
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = _width;
+ fmt.fmt.pix.height = _height;
+ fmt.fmt.pix.field = V4L2_FIELD_NONE;
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_XBGR32;
+
+ if (-1 == xioctl(_fd, VIDIOC_S_FMT, &fmt))
+ errno_exit("VIDIOC_S_FMT");
+
+ init_mmap();
+
+ return 0;
+}
+
+void CapturingItem::start_capturing(void)
+{
+ unsigned int i;
+ enum v4l2_buf_type type;
+
+ for (i = 0; i < n_buffers; ++i) {
+ struct v4l2_buffer buf;
+
+ CLEAR(buf);
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = i;
+
+ if (-1 == xioctl(_fd, VIDIOC_QBUF, &buf))
+ errno_exit("VIDIOC_QBUF");
+ }
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (-1 == xioctl(_fd, VIDIOC_STREAMON, &type))
+ errno_exit("VIDIOC_STREAMON");
+}
+
+unsigned char* CapturingItem::snap_frame(void)
+{
+ int index = 0;
+ for (;;)
+ {
+ fd_set fds;
+ struct timeval tv;
+ int r;
+
+ FD_ZERO(&fds);
+ FD_SET(_fd, &fds);
+
+ /* Timeout. */
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+
+ r = select(_fd + 1, &fds, NULL, NULL, &tv);
+
+ if (-1 == r)
+ {
+ if (EINTR == errno)
+ continue;
+ errno_exit("select");
+ }
+
+ if (0 == r)
+ {
+ fprintf(stderr, "select timeout!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ index = read_frame();
+ if (-1 != index)
+ break;
+ /* EAGAIN (continue select loop). */
+ }
+
+ return (unsigned char*)(p_buffers)[index].start;
+}
+
+int CapturingItem::read_frame(void)
+{
+ struct v4l2_buffer buf;
+
+ CLEAR(buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+
+ if (-1 == xioctl(_fd, VIDIOC_DQBUF, &buf))
+ {
+ switch (errno)
+ {
+ case EAGAIN:
+ return -1;
+
+ case EIO:
+ /* Could ignore EIO. */
+ default:
+ errno_exit("VIDIOC_DQBUF");
+ }
+ }
+
+ assert(buf.index < n_buffers);
+
+
+
+ if (-1 == xioctl(_fd, VIDIOC_QBUF, &buf))
+ errno_exit("VIDIOC_QBUF");
+
+ return buf.index;
+}
+
+void CapturingItem::errno_exit(const char *s)
+{
+ fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno));
+ exit(EXIT_FAILURE);
+}
+
+int CapturingItem::xioctl(int fh, int request, void *arg)
+{
+ int r;
+
+ do {
+ r = ioctl(fh, request, arg);
+ } while (-1 == r && EINTR == errno);
+
+ return r;
+}
+
+void CapturingItem::uninit_device(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < n_buffers; ++i)
+ if (-1 == munmap((p_buffers)[i].start, (p_buffers)[i].length))
+ errno_exit("munmap");
+
+ free(p_buffers);
+}
+
+void CapturingItem::init_read(unsigned int buffer_size)
+{
+ p_buffers = (struct buffer*)(calloc(1, sizeof(*p_buffers)));
+
+ if (!p_buffers) {
+ fprintf(stderr, "Out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+
+ (p_buffers)[0].length = buffer_size;
+ (p_buffers)[0].start = malloc(buffer_size);
+
+ if (!(p_buffers)[0].start) {
+ fprintf(stderr, "Out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
+void CapturingItem::init_mmap(void)
+{
+ struct v4l2_requestbuffers req;
+
+ CLEAR(req);
+
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_MMAP;
+
+ if (-1 == xioctl(_fd, VIDIOC_REQBUFS, &req)) {
+ if (EINVAL == errno) {
+ fprintf(stderr, "%s does not support "
+ "memory mapping\n", _dev_name.c_str());
+ exit(EXIT_FAILURE);
+ } else {
+ errno_exit("VIDIOC_REQBUFS");
+ }
+ }
+
+ if (req.count < 2) {
+ fprintf(stderr, "Insufficient buffer memory on %s\n",
+ _dev_name.c_str());
+ exit(EXIT_FAILURE);
+ }
+
+ p_buffers = (struct buffer*)(calloc(req.count, sizeof(*p_buffers)));
+
+ if (!p_buffers) {
+ fprintf(stderr, "Out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
+ struct v4l2_buffer buf;
+
+ CLEAR(buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = n_buffers;
+
+ if (-1 == xioctl(_fd, VIDIOC_QUERYBUF, &buf))
+ errno_exit("VIDIOC_QUERYBUF");
+
+ (p_buffers)[n_buffers].length = buf.length;
+ (p_buffers)[n_buffers].start =
+ mmap(NULL /* Start from anywhere */,
+ buf.length,
+ PROT_READ | PROT_WRITE /* Required */,
+ MAP_SHARED /* Recommended */,
+ _fd, buf.m.offset);
+
+ if (MAP_FAILED == (p_buffers)[n_buffers].start)
+ errno_exit("mmap");
+ }
+}
+
+void CapturingItem::init_userp(unsigned int buffer_size)
+{
+ struct v4l2_requestbuffers req;
+
+ CLEAR(req);
+
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_USERPTR;
+
+ if (-1 == xioctl(_fd, VIDIOC_REQBUFS, &req)) {
+ if (EINVAL == errno) {
+ fprintf(stderr, "%s does not support "
+ "user pointer i/o\n", _dev_name.c_str());
+ exit(EXIT_FAILURE);
+ } else {
+ errno_exit("VIDIOC_REQBUFS");
+ }
+ }
+
+ p_buffers = (struct buffer*)(calloc(4, sizeof(*p_buffers)));
+
+ if (!p_buffers) {
+ fprintf(stderr, "Out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for (n_buffers = 0; n_buffers < 4; ++n_buffers) {
+ (p_buffers)[n_buffers].length = buffer_size;
+ (p_buffers)[n_buffers].start = malloc(buffer_size);
+
+ if (!(p_buffers)[n_buffers].start) {
+ fprintf(stderr, "Out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
+void CapturingItem::close_device(void)
+{
+ if (-1 == close(_fd))
+ errno_exit("close");
+
+ _fd = -1;
+}
diff --git a/app/capturing.h b/app/capturing.h
new file mode 100644
index 0000000..599cd5c
--- /dev/null
+++ b/app/capturing.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef CAPTURING_H
+#define CAPTURING_H
+
+
+class CapturingItem
+{
+
+public:
+ CapturingItem();
+ ~CapturingItem();
+ int open_device(int dev);
+ int init_device(void);
+ void start_capturing(void);
+ void close_device(void);
+ unsigned char* snap_frame(void);
+ int width(void) const
+ {
+ return _width;
+ }
+
+ int height(void) const
+ {
+ return _height;
+ }
+
+
+private:
+ struct buffer {
+ void *start;
+ size_t length;
+ };
+
+ std::string _dev_name;
+ int _fd;
+ struct buffer *p_buffers;
+ unsigned int n_buffers;
+ int _fps_count;
+ int _framerate;
+ int _timeout; /* secs */
+ int _left;
+ int _top;
+ int _width;
+ int _height;
+
+ void errno_exit(const char *s);
+ int xioctl(int fh, int request, void *arg);
+ void uninit_device(void);
+ void init_read(unsigned int buffer_size);
+ void init_mmap(void);
+ void init_userp(unsigned int buffer_size);
+ int read_frame(void);
+};
+#endif /* CAPTURING_H */
diff --git a/app/config.tests/libhomescreen/libhomescreen.cpp b/app/config.tests/libhomescreen/libhomescreen.cpp
new file mode 100755
index 0000000..d698b05
--- /dev/null
+++ b/app/config.tests/libhomescreen/libhomescreen.cpp
@@ -0,0 +1,8 @@
+#include <libhomescreen.hpp>
+
+int main(int argc,char **argv)
+{
+ LibHomeScreen libHomeScreen;
+ return 0;
+}
+
diff --git a/app/config.tests/libhomescreen/libhomescreen.pro b/app/config.tests/libhomescreen/libhomescreen.pro
new file mode 100755
index 0000000..eb4e8f3
--- /dev/null
+++ b/app/config.tests/libhomescreen/libhomescreen.pro
@@ -0,0 +1,5 @@
+SOURCES = libhomescreen.cpp
+
+CONFIG -= qt
+CONFIG += link_pkgconfig
+PKGCONFIG += homescreen
diff --git a/app/images/HMI_Radiocontrol_Car.png b/app/images/HMI_Radiocontrol_Car.png
new file mode 100644
index 0000000..b868dd6
--- /dev/null
+++ b/app/images/HMI_Radiocontrol_Car.png
Binary files differ
diff --git a/app/images/images.qrc b/app/images/images.qrc
new file mode 100644
index 0000000..9cce024
--- /dev/null
+++ b/app/images/images.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>HMI_Radiocontrol_Car.png</file>
+ <file>triangle_front_full.png</file>
+ <file>triangle_back_full.png</file>
+ </qresource>
+</RCC>
diff --git a/app/images/triangle_back_full.png b/app/images/triangle_back_full.png
new file mode 100644
index 0000000..bd49f65
--- /dev/null
+++ b/app/images/triangle_back_full.png
Binary files differ
diff --git a/app/images/triangle_front_full.png b/app/images/triangle_front_full.png
new file mode 100644
index 0000000..87ef5d3
--- /dev/null
+++ b/app/images/triangle_front_full.png
Binary files differ
diff --git a/app/main.cpp b/app/main.cpp
new file mode 100644
index 0000000..5f50323
--- /dev/null
+++ b/app/main.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 DENSO TEN Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <QtAGLExtras/AGLApplication>
+#include <QtQml/QQmlApplicationEngine>
+#include "camera.h"
+
+
+int main(int argc, char *argv[])
+{
+ AGLApplication app(argc, argv);
+ app.setApplicationName("AROUNDVIEW");
+ app.setupApplicationRole("aroundview"); // fall into "fallback" in windowmanager
+
+ /* Registrate generated class */
+ qmlRegisterType<CameraItem>("OpenCV", 1, 0, "Camera0");
+ qmlRegisterType<CameraItem>("OpenCV", 1, 0, "Camera1");
+ qmlRegisterType<CameraItem>("OpenCV", 1, 0, "Camera2");
+ qmlRegisterType<CameraItem>("OpenCV", 1, 0, "Camera3");
+
+ app.load(QUrl(QStringLiteral("qrc:/AroundView.qml")));
+ return app.exec();
+
+}