Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
avmIntergration
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马乐
avmIntergration
Commits
41e46616
Commit
41e46616
authored
Oct 11, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加channel
parent
7773cb05
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
24 deletions
+131
-24
MainActivity.kt
app/src/main/java/com/intergration/avm/MainActivity.kt
+34
-11
avm.kt
app/src/main/java/com/intergration/avm/avm.kt
+2
-11
DefaultDispatchersProvider.kt
.../com/intergration/avm/utils/DefaultDispatchersProvider.kt
+46
-0
DispatchersProvider.kt
...in/java/com/intergration/avm/utils/DispatchersProvider.kt
+45
-0
Utils.kt
app/src/main/java/com/intergration/avm/utils/Utils.kt
+4
-2
No files found.
app/src/main/java/com/intergration/avm/MainActivity.kt
View file @
41e46616
...
...
@@ -38,6 +38,7 @@ import kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.cancel
import
kotlinx.coroutines.channels.Channel
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
...
...
@@ -69,6 +70,8 @@ class MainActivity : AppCompatActivity() {
private
var
job
:
Job
?
=
null
private
var
avmStartScope
:
AvmCoroutineScope
?=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
binding
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
...
...
@@ -130,7 +133,11 @@ class MainActivity : AppCompatActivity() {
}
binding
.
startAvm
.
setOnClickListener
{
openAuxiliaryPresentation
()
avmCoroutineScope
.
launch
{
if
(
avmStartScope
==
null
)
{
avmStartScope
=
AvmCoroutineScope
(
AvmCoroutineContext
(
engine
=
avmEngine
)
+
Dispatchers
.
IO
+
COROUTINE_AVM
+
Job
())
}
val
channel
=
Channel
<
Boolean
>()
avmStartScope
?.
launch
{
launch
(
Dispatchers
.
Default
)
{
avmFrontCamera
.
startPictureSequence
(
PictureSequenceSource
.
GENERAL_CAMERA
,
...
...
@@ -138,6 +145,9 @@ class MainActivity : AppCompatActivity() {
if
(
status
==
SpmCameraDevice
.
ImageDataCallback
.
IMAGE_STATUS_SUCCEEDED
)
{
ArcAVMInputImageFactory
.
ofFront
(
data
).
also
{
avmInputImages
[
0
]
=
it
launch
{
channel
.
send
(
true
)
}
}
}
}
...
...
@@ -150,6 +160,9 @@ class MainActivity : AppCompatActivity() {
if
(
status
==
SpmCameraDevice
.
ImageDataCallback
.
IMAGE_STATUS_SUCCEEDED
)
{
ArcAVMInputImageFactory
.
ofRight
(
data
).
also
{
avmInputImages
[
1
]
=
it
launch
{
channel
.
send
(
true
)
}
}
}
}
...
...
@@ -162,6 +175,9 @@ class MainActivity : AppCompatActivity() {
if
(
status
==
SpmCameraDevice
.
ImageDataCallback
.
IMAGE_STATUS_SUCCEEDED
)
{
ArcAVMInputImageFactory
.
ofBack
(
data
).
also
{
avmInputImages
[
2
]
=
it
launch
{
channel
.
send
(
true
)
}
}
}
}
...
...
@@ -174,6 +190,9 @@ class MainActivity : AppCompatActivity() {
if
(
status
==
SpmCameraDevice
.
ImageDataCallback
.
IMAGE_STATUS_SUCCEEDED
)
{
ArcAVMInputImageFactory
.
ofLeft
(
data
).
also
{
avmInputImages
[
3
]
=
it
launch
{
channel
.
send
(
true
)
}
}
}
}
...
...
@@ -185,14 +204,18 @@ class MainActivity : AppCompatActivity() {
}
LogUtils
.
d
(
"准备播放融合图..."
)
if
(
spUtils
.
getBoolean
(
CALIB_RESULT
)
&&
spUtils
.
getBoolean
(
LOOKUP_TABLE
))
{
val
result
=
coroutineContext
[
AvmCoroutineContext
]
?.
engine
?.
drawAVM
(
31
,
avmInputImages
,
outputImageList
)
if
(
result
==
ArcErrorInfo
.
ARC_ERROR_OK
)
{
if
(
outputImageList
.
isNotEmpty
())
{
feedData
(
outputImageList
[
0
].
imageData
)
launch
(
Dispatchers
.
Default
)
{
while
(
channel
.
receive
())
{
val
result
=
coroutineContext
[
AvmCoroutineContext
]
?.
engine
?.
drawAVM
(
31
,
avmInputImages
,
outputImageList
)
if
(
result
==
ArcErrorInfo
.
ARC_ERROR_OK
)
{
if
(
outputImageList
.
isNotEmpty
())
{
feedData
(
outputImageList
[
0
].
imageData
)
}
}
}
}
}
else
{
...
...
@@ -203,13 +226,13 @@ class MainActivity : AppCompatActivity() {
}
}
binding
.
stopAvm
.
setOnClickListener
{
avm
CoroutineScope
.
launch
{
avm
StartScope
?
.
launch
{
avmLeftCamera
.
stopPictureSequence
(
PictureSequenceSource
.
GENERAL_CAMERA
)
avmFrontCamera
.
stopPictureSequence
(
PictureSequenceSource
.
GENERAL_CAMERA
)
avmRightCamera
.
stopPictureSequence
(
PictureSequenceSource
.
GENERAL_CAMERA
)
avmBackCamera
.
stopPictureSequence
(
PictureSequenceSource
.
GENERAL_CAMERA
)
cancel
(
kotlinx
.
coroutines
.
CancellationException
(
"Click Stop Avm Button"
))
}
avmCoroutineScope
.
cancel
(
kotlinx
.
coroutines
.
CancellationException
(
"Click Stop Avm Button"
))
closeAuxiliaryPresentation
()
}
}
...
...
app/src/main/java/com/intergration/avm/avm.kt
View file @
41e46616
...
...
@@ -72,17 +72,8 @@ val avmCoroutineScope by lazy {
AvmCoroutineScope
(
AvmCoroutineContext
(
engine
=
avmEngine
)
+
Dispatchers
.
IO
+
COROUTINE_AVM
)
}
class
AvmCoroutineScope
(
context
:
CoroutineContext
)
:
Closeable
,
CoroutineScope
{
override
val
coroutineContext
:
CoroutineContext
=
context
+
avmJob
override
fun
close
()
{
LogUtils
.
e
(
"Avm关闭"
)
SmartPlatformManager
.
get
().
closeCameraDevice
(
avmFrontCamera
)
SmartPlatformManager
.
get
().
closeCameraDevice
(
avmLeftCamera
)
SmartPlatformManager
.
get
().
closeCameraDevice
(
avmRightCamera
)
SmartPlatformManager
.
get
().
closeCameraDevice
(
avmBackCamera
)
coroutineContext
[
AvmCoroutineContext
]
?.
engine
?.
unInit
()
coroutineContext
.
cancel
()
}
class
AvmCoroutineScope
(
context
:
CoroutineContext
)
:
CoroutineScope
{
override
val
coroutineContext
:
CoroutineContext
=
context
}
fun
ArcVisDriveAVMEngine
.
initializeAvmParams
(
calibResultPath
:
File
,
lookupPath
:
File
):
Int
{
...
...
app/src/main/java/com/intergration/avm/utils/DefaultDispatchersProvider.kt
0 → 100644
View file @
41e46616
/*
* Copyright (c) 2021 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
* distribute, sublicense, create a derivative work, and/or sell copies of the
* Software in any work that is designed, intended, or marketed for pedagogical or
* instructional purposes related to programming, coding, application development,
* or information technology. Permission for such use, copying, modification,
* merger, publication, distribution, sublicensing, creation of derivative works,
* or sale is expressly withheld.
*
* This project and source code may use libraries or frameworks that are
* released under various Open-Source licenses. Use of those libraries and
* frameworks are governed by their own individual licenses.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.intergration.avm.utils
import
kotlinx.coroutines.Dispatchers
class
DefaultDispatchersProvider
:
DispatchersProvider
{
override
fun
io
()
=
Dispatchers
.
IO
override
fun
main
()
=
Dispatchers
.
Main
override
fun
avm
()
=
Dispatchers
.
Default
override
fun
camera
()
=
Dispatchers
.
IO
}
\ No newline at end of file
app/src/main/java/com/intergration/avm/utils/DispatchersProvider.kt
0 → 100644
View file @
41e46616
/*
* Copyright (c) 2021 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
* distribute, sublicense, create a derivative work, and/or sell copies of the
* Software in any work that is designed, intended, or marketed for pedagogical or
* instructional purposes related to programming, coding, application development,
* or information technology. Permission for such use, copying, modification,
* merger, publication, distribution, sublicensing, creation of derivative works,
* or sale is expressly withheld.
*
* This project and source code may use libraries or frameworks that are
* released under various Open-Source licenses. Use of those libraries and
* frameworks are governed by their own individual licenses.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.intergration.avm.utils
import
kotlinx.coroutines.CoroutineDispatcher
interface
DispatchersProvider
{
fun
io
():
CoroutineDispatcher
fun
main
():
CoroutineDispatcher
fun
avm
():
CoroutineDispatcher
fun
camera
():
CoroutineDispatcher
}
\ No newline at end of file
app/src/main/java/com/intergration/avm/utils/Utils.kt
View file @
41e46616
...
...
@@ -51,8 +51,10 @@ fun Context.openAuxiliaryPresentation(){
}
fun
Context
.
closeAuxiliaryPresentation
(){
multiScreenService
?.
dismissSecondPresentation
()
unbindService
(
serviceConnection
)
if
(
multiScreenService
!=
null
)
{
multiScreenService
?.
dismissSecondPresentation
()
unbindService
(
serviceConnection
)
}
}
fun
feedData
(
data
:
ByteArray
){
...
...
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