Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tikka
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
Service Desk
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
clients
python
Tikka
Commits
ac988aab
Commit
ac988aab
authored
2 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add debug logs in scan_qr_code.py
parent
7ba47654
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tikka/slots/pyqt/windows/main.py
+2
-0
2 additions, 0 deletions
tikka/slots/pyqt/windows/main.py
tikka/slots/pyqt/windows/scan_qr_code.py
+20
-5
20 additions, 5 deletions
tikka/slots/pyqt/windows/scan_qr_code.py
with
22 additions
and
5 deletions
tikka/slots/pyqt/windows/main.py
+
2
−
0
View file @
ac988aab
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
sys
import
sys
from
typing
import
TYPE_CHECKING
,
Any
,
List
,
Optional
from
typing
import
TYPE_CHECKING
,
Any
,
List
,
Optional
...
@@ -506,6 +507,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -506,6 +507,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
:return:
:return:
"""
"""
logging
.
debug
(
"
create instance of ScanQRCodeWindow
"
)
ScanQRCodeWindow
(
self
.
application
,
self
).
exec_
()
ScanQRCodeWindow
(
self
.
application
,
self
).
exec_
()
def
open_add_address_window
(
self
)
->
None
:
def
open_add_address_window
(
self
)
->
None
:
...
...
This diff is collapsed.
Click to expand it.
tikka/slots/pyqt/windows/scan_qr_code.py
+
20
−
5
View file @
ac988aab
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
sys
import
sys
from
typing
import
List
,
Optional
from
typing
import
List
,
Optional
...
@@ -65,16 +66,21 @@ class QRCodeVideoSurface(QAbstractVideoSurface):
...
@@ -65,16 +66,21 @@ class QRCodeVideoSurface(QAbstractVideoSurface):
self
.
video_label
=
video_label
self
.
video_label
=
video_label
# initialize the OpenCV QRCode detector
# initialize the OpenCV QRCode detector
logging
.
debug
(
"
Create OpenVC qrcode detector instance with cv2.QRCodeDetector()
"
)
self
.
detector
=
cv2
.
QRCodeDetector
()
self
.
detector
=
cv2
.
QRCodeDetector
()
def
supportedPixelFormats
(
def
supportedPixelFormats
(
self
,
type
:
QAbstractVideoBuffer
.
HandleType
=
QAbstractVideoBuffer
.
NoHandle
self
,
type
:
QAbstractVideoBuffer
.
HandleType
=
QAbstractVideoBuffer
.
NoHandle
)
->
List
[
QVideoFrame
.
PixelFormat
]:
)
->
List
[
QVideoFrame
.
PixelFormat
]:
result
=
[]
result
=
[]
logging
.
debug
(
"
supportedPixelFormats Type = %s
"
,
type
)
if
type
==
QtMultimedia
.
QAbstractVideoBuffer
.
NoHandle
:
if
type
==
QtMultimedia
.
QAbstractVideoBuffer
.
NoHandle
:
result
=
[
logging
.
debug
(
QtMultimedia
.
QVideoFrame
.
Format_RGB32
,
"
supportedPixelFormats returns QtMultimedia.QVideoFrame.Format_RGB24
"
]
)
result
=
[
QtMultimedia
.
QVideoFrame
.
Format_RGB24
]
return
result
return
result
...
@@ -178,19 +184,26 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
...
@@ -178,19 +184,26 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
self
.
addressValueLabel
.
setFont
(
monospace_font
)
self
.
addressValueLabel
.
setFont
(
monospace_font
)
# fill form
# fill form
if
self
.
check_camera_availability
()
is
False
:
camera_available
=
self
.
check_camera_availability
()
if
camera_available
is
False
:
self
.
errorLabel
.
setText
(
self
.
_
(
"
No camera available
"
))
self
.
errorLabel
.
setText
(
self
.
_
(
"
No camera available
"
))
else
:
else
:
logging
.
debug
(
"
Create instance of QCamera()
"
)
self
.
camera
=
QCamera
()
self
.
camera
=
QCamera
()
logging
.
debug
(
"
Create instance of QRCodeVideoSurface()
"
)
self
.
video_surface
=
QRCodeVideoSurface
(
self
.
videoLabel
)
self
.
video_surface
=
QRCodeVideoSurface
(
self
.
videoLabel
)
logging
.
debug
(
"
set VideoSurface instance as camera viewfinder with camera.setViewfinder(self.video_surface)
"
)
self
.
camera
.
setViewfinder
(
self
.
video_surface
)
self
.
camera
.
setViewfinder
(
self
.
video_surface
)
logging
.
debug
(
"
Start camera with camera.start()
"
)
self
.
camera
.
start
()
self
.
camera
.
start
()
# buttons
# buttons
self
.
buttonBox
.
button
(
self
.
buttonBox
.
Ok
).
setEnabled
(
False
)
self
.
buttonBox
.
button
(
self
.
buttonBox
.
Ok
).
setEnabled
(
False
)
# events
# events
if
self
.
check_
camera_availab
ility
()
is
True
:
if
camera_availab
le
is
True
:
self
.
video_surface
.
detected
.
connect
(
self
.
qrcode_detected
)
self
.
video_surface
.
detected
.
connect
(
self
.
qrcode_detected
)
self
.
buttonBox
.
accepted
.
connect
(
self
.
on_accepted_button
)
self
.
buttonBox
.
accepted
.
connect
(
self
.
on_accepted_button
)
self
.
buttonBox
.
rejected
.
connect
(
self
.
close
)
self
.
buttonBox
.
rejected
.
connect
(
self
.
close
)
...
@@ -202,6 +215,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
...
@@ -202,6 +215,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
:return:
:return:
"""
"""
logging
.
debug
(
"
Check if there is a webcam : QCameraInfo.availableCameras()
"
)
return
len
(
QCameraInfo
.
availableCameras
())
>
0
return
len
(
QCameraInfo
.
availableCameras
())
>
0
def
qrcode_detected
(
self
,
data
:
str
):
def
qrcode_detected
(
self
,
data
:
str
):
...
@@ -246,6 +260,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
...
@@ -246,6 +260,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog):
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
qapp
=
QApplication
(
sys
.
argv
)
qapp
=
QApplication
(
sys
.
argv
)
application_
=
Application
(
DATA_PATH
)
application_
=
Application
(
DATA_PATH
)
ScanQRCodeWindow
(
application_
).
exec_
()
ScanQRCodeWindow
(
application_
).
exec_
()
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