Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
deskscreen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kowis-projects
deskscreen
Commits
f48e1e16
Commit
f48e1e16
authored
Apr 02, 2019
by
David
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding gizmos and designing camera flow
parent
ce721e07
Pipeline
#4
failed with stages
in 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
9 deletions
+64
-9
src/main/kotlin/is/kow/deskscreen/camera/CameraController.kt
src/main/kotlin/is/kow/deskscreen/camera/CameraController.kt
+48
-7
src/main/kotlin/is/kow/deskscreen/camera/CameraView.kt
src/main/kotlin/is/kow/deskscreen/camera/CameraView.kt
+16
-2
No files found.
src/main/kotlin/is/kow/deskscreen/camera/CameraController.kt
View file @
f48e1e16
package
`is`.kow.deskscreen.camera
import
`is`.kow.deskscreen.MainController
import
com.github.thomasnield.rxkotlinfx.doOnNextFx
import
com.github.thomasnield.rxkotlinfx.observeOnFx
import
com.hopding.jrpicam.RPiCamera
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
javafx.event.ActionEvent
import
mu.KotlinLogging
import
tornadofx.*
import
java.awt.image.BufferedImage
import
java.nio.file.Paths
...
...
@@ -14,6 +18,8 @@ class CameraController : Controller() {
private
val
camera
:
RPiCamera
?
private
val
mainController
:
MainController
by
inject
()
private
val
cameraStateModel
:
CameraStateModel
by
inject
()
init
{
//Only care that the folders exist
//TODO: add a cleanup mechanism that only keeps some number of pictures, or some amount of space or something
...
...
@@ -33,11 +39,46 @@ class CameraController : Controller() {
}
}
fun
takePicture
():
BufferedImage
?
{
return
camera
?.
setRotation
(
270
)
?.
setDateTimeOn
()
?.
setFullPreviewOn
()
?.
takeBufferedStill
()
fun
takePicture
(
actionEvents
:
Observable
<
ActionEvent
>)
{
actionEvents
.
observeOn
(
Schedulers
.
io
())
.
doOnNextFx
{
//UPdate state
cameraStateModel
.
state
.
set
(
PictureTakingState
.
TAKING
)
}
.
map
{
val
timeout
=
5
//Handles the timer countdown
Observable
.
range
(
timeout
,
0
)
.
observeOnFx
()
.
map
{
cameraStateModel
.
countdownPercentage
.
value
=
it
/
timeout
.
toDouble
()
}
.
subscribe
()
//The camera blocks things. need to also start the countdown observable for the thing.
//TODO: when it's not the pi, just use some image with the same dimensions!
camera
?.
setRotation
(
270
)
?.
setDateTimeOn
()
?.
setTimeout
(
timeout
)
?.
setFullPreviewOn
()
?.
takeBufferedStill
()
}
.
doOnNextFx
{
cameraStateModel
.
image
.
value
=
it
cameraStateModel
.
state
.
set
(
PictureTakingState
.
PREVIEWING
)
}
.
subscribe
()
}
fun
keepPicture
()
{
}
fun
rejectPicture
()
{
}
}
\ No newline at end of file
src/main/kotlin/is/kow/deskscreen/camera/CameraView.kt
View file @
f48e1e16
package
`is`.kow.deskscreen.camera
import
com.github.thomasnield.rxkotlinfx.actionEvents
import
javafx.beans.binding.Bindings
import
javafx.beans.binding.BooleanBinding
import
javafx.beans.property.SimpleDoubleProperty
import
javafx.beans.property.SimpleObjectProperty
import
javafx.geometry.Pos
import
javafx.scene.control.ProgressBar
...
...
@@ -22,6 +24,9 @@ class CameraState {
val
stateProperty
=
SimpleObjectProperty
<
PictureTakingState
>(
this
,
"state"
,
PictureTakingState
.
READY
)
var
state
by
stateProperty
val
countdownPercentageProperty
=
SimpleDoubleProperty
(
this
,
"countdown"
,
5.0
)
var
countdownPercentage
by
countdownPercentageProperty
}
class
CameraStateModel
:
ItemViewModel
<
CameraState
>()
{
...
...
@@ -29,21 +34,28 @@ class CameraStateModel : ItemViewModel<CameraState>() {
val
image
:
SimpleObjectProperty
<
BufferedImage
>
=
bind
(
CameraState
::
imageProperty
)
val
state
:
SimpleObjectProperty
<
PictureTakingState
>
=
bind
(
CameraState
::
stateProperty
)
val
countdownPercentage
=
bind
(
CameraState
::
countdownPercentageProperty
)
val
previewing
:
BooleanBinding
=
Bindings
.
equal
(
PictureTakingState
.
PREVIEWING
,
state
)
val
readyToTake
:
BooleanBinding
=
Bindings
.
equal
(
PictureTakingState
.
READY
,
state
)
//Huh, why isn't that true to start with....
val
readyToTake
:
BooleanBinding
=
Bindings
.
equal
(
PictureTakingState
.
READY
,
state
)
}
class
CameraView
:
View
()
{
private
val
logger
=
KotlinLogging
.
logger
{}
private
val
cameraLoadingView
:
CameraLoadingView
by
inject
()
private
val
cameraStateModel
:
CameraStateModel
by
inject
()
private
val
cameraController
:
CameraController
by
inject
()
init
{
//set up the state, it's weird that I even have to do this, the initial value doesn't work
cameraStateModel
.
state
.
set
(
PictureTakingState
.
READY
)
}
override
fun
onDock
()
{
//Hook up an observable to the state to have it swap views when ready
}
override
val
root
=
borderpane
{
//Left and right can be 160px max
...
...
@@ -59,6 +71,8 @@ class CameraView : View() {
enableWhen
{
cameraStateModel
.
previewing
}
cameraController
.
takePicture
(
actionEvents
())
//Picture is good, enabled only after a capture
//Make it green
}
...
...
@@ -73,7 +87,7 @@ class CameraView : View() {
label
(
"Delay to take picture"
)
hbox
{
progressbar
{
//countdown timer for photo taking
bind
(
cameraStateModel
.
countdownPercentage
)
//Set max width to the same as something?
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment