Skip to content

Transforming preview sample, with injection. This way I can connect my CVCamera object to other objects in the cpp part of the code. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 78 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,81 @@
#Temp build files
*.pyc
build*/

#Temp QT files
*.user
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------

#Annoying files
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash

# qtcreator generated files
*.pro.user*

# xemacs temporary files
*.flc

# Vim temporary files
.*.swp

# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*

# MinGW generated files
*.Debug
*.Release

# Python byte code
*.pyc

# Binaries
# --------
*.dll
*.exe
build-android-*
build-macos-*
*.txt.user
*.pro.user

m/
q/
*build-preview*
# No Wasm because QtMultimedia is not implemented yet.
3 changes: 2 additions & 1 deletion qml-cvcamera.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ SOURCES += \
src/CameraThread.cpp \
src/BetterVideoCapture.cpp

LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio
INCLUDEPATH += $$(OPENCV_DIR)/include/opencv4
LIBS += -L$$(OPENCV_DIR)/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio

android {
HEADERS += \
Expand Down
6 changes: 6 additions & 0 deletions samples/preview/preview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ SOURCES += src/main.cpp

RESOURCES += qml.qrc

INCLUDEPATH += $$(OPENCV_DIR)/include/opencv4
INCLUDEPATH += ../../src
LIBS += -L$$(OPENCV_DIR)/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio
LIBS += -L/Users/jg/Code/opensource/qt/5.12.3/clang_64/qml/CVCamera/ -lcvcameraplugin


android {
target.path = /libs/armeabi-v7a
export(target.path)
Expand Down
13 changes: 13 additions & 0 deletions samples/preview/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <QSize>
#include <CVCamera.h>
#include <QQmlContext>
#include <QGuiApplication>
#include <QQmlApplicationEngine>

Expand All @@ -6,6 +9,16 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;

//Instantiate Camera.
CVCamera camera;
camera.setSize(QSize(640,480));



auto qmlContext = engine.rootContext();
qmlContext->setContextProperty("camerax", &camera);

engine.load(QUrl(QStringLiteral("qrc:/src/main.qml")));

return app.exec();
Expand Down
23 changes: 9 additions & 14 deletions samples/preview/src/main.qml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Controls 2.5
import QtMultimedia 5.0
import CVCamera 1.0

Window {
ApplicationWindow {
visible: true

//Width and height stuff is for desktop only, they seem to be ignored on Android (this is expected good behavior)
width: camera.size.width
height: camera.size.height
maximumHeight: camera.size.height
maximumWidth: camera.size.width
width: camerax.size.width
height: camerax.size.height
maximumHeight: camerax.size.height
maximumWidth: camerax.size.width

CVCamera {
id: camera
device: deviceBox.currentIndex
size: "640x480"
}


VideoOutput {
anchors.top: imageSizeField.top
id: output
source: camera
source: camerax
}

TextField {
Expand All @@ -42,6 +37,6 @@ Window {
id: deviceBox
width: 200
anchors.left: imageSizeSetButton.right
model: camera.deviceList
model: camerax.deviceList
}
}