Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a5ee07d3
Commit
a5ee07d3
authored
Oct 22, 2012
by
Alexander Smorkalov
Committed by
Andrey Kamaev
Oct 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Image manipulations sample ported on new framework.
parent
898320a0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
125 deletions
+11
-125
image_manipulations_surface_view.xml
...pulations/res/layout/image_manipulations_surface_view.xml
+11
-0
ImageManipulationsActivity.java
...amples/imagemanipulations/ImageManipulationsActivity.java
+0
-0
ImageManipulationsView.java
...cv/samples/imagemanipulations/ImageManipulationsView.java
+0
-0
SampleCvViewBase.java
...g/opencv/samples/imagemanipulations/SampleCvViewBase.java
+0
-125
No files found.
samples/android/image-manipulations/res/layout/image_manipulations_surface_view.xml
0 → 100644
View file @
a5ee07d3
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<org.opencv.framework.OpenCvJavaCameraView
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:id=
"@+id/image_manipulations_activity_surface_view"
/>
</LinearLayout>
samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java
View file @
a5ee07d3
This diff is collapsed.
Click to expand it.
samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsView.java
deleted
100644 → 0
View file @
898320a0
This diff is collapsed.
Click to expand it.
samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/SampleCvViewBase.java
deleted
100644 → 0
View file @
898320a0
package
org
.
opencv
.
samples
.
imagemanipulations
;
import
java.util.List
;
import
org.opencv.core.Size
;
import
org.opencv.highgui.VideoCapture
;
import
org.opencv.highgui.Highgui
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.util.Log
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
public
abstract
class
SampleCvViewBase
extends
SurfaceView
implements
SurfaceHolder
.
Callback
,
Runnable
{
private
static
final
String
TAG
=
"OCVSample::BaseView"
;
private
SurfaceHolder
mHolder
;
private
VideoCapture
mCamera
;
private
FpsMeter
mFps
;
public
SampleCvViewBase
(
Context
context
)
{
super
(
context
);
mHolder
=
getHolder
();
mHolder
.
addCallback
(
this
);
mFps
=
new
FpsMeter
();
Log
.
i
(
TAG
,
"Instantiated new "
+
this
.
getClass
());
}
public
synchronized
boolean
openCamera
()
{
Log
.
i
(
TAG
,
"Opening Camera"
);
mCamera
=
new
VideoCapture
(
Highgui
.
CV_CAP_ANDROID
);
if
(!
mCamera
.
isOpened
())
{
releaseCamera
();
Log
.
e
(
TAG
,
"Can't open native camera"
);
return
false
;
}
return
true
;
}
public
synchronized
void
releaseCamera
()
{
Log
.
i
(
TAG
,
"Releasing Camera"
);
if
(
mCamera
!=
null
)
{
mCamera
.
release
();
mCamera
=
null
;
}
}
public
synchronized
void
setupCamera
(
int
width
,
int
height
)
{
if
(
mCamera
!=
null
&&
mCamera
.
isOpened
())
{
Log
.
i
(
TAG
,
"Setup Camera - "
+
width
+
"x"
+
height
);
List
<
Size
>
sizes
=
mCamera
.
getSupportedPreviewSizes
();
int
mFrameWidth
=
width
;
int
mFrameHeight
=
height
;
// selecting optimal camera preview size
{
double
minDiff
=
Double
.
MAX_VALUE
;
for
(
Size
size
:
sizes
)
{
if
(
Math
.
abs
(
size
.
height
-
height
)
<
minDiff
)
{
mFrameWidth
=
(
int
)
size
.
width
;
mFrameHeight
=
(
int
)
size
.
height
;
minDiff
=
Math
.
abs
(
size
.
height
-
height
);
}
}
}
mCamera
.
set
(
Highgui
.
CV_CAP_PROP_FRAME_WIDTH
,
mFrameWidth
);
mCamera
.
set
(
Highgui
.
CV_CAP_PROP_FRAME_HEIGHT
,
mFrameHeight
);
}
}
public
void
surfaceChanged
(
SurfaceHolder
_holder
,
int
format
,
int
width
,
int
height
)
{
Log
.
i
(
TAG
,
"called surfaceChanged"
);
setupCamera
(
width
,
height
);
}
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
Log
.
i
(
TAG
,
"called surfaceCreated"
);
(
new
Thread
(
this
)).
start
();
}
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
Log
.
i
(
TAG
,
"called surfaceDestroyed"
);
}
protected
abstract
Bitmap
processFrame
(
VideoCapture
capture
);
public
void
run
()
{
Log
.
i
(
TAG
,
"Started processing thread"
);
mFps
.
init
();
while
(
true
)
{
Bitmap
bmp
=
null
;
synchronized
(
this
)
{
if
(
mCamera
==
null
)
break
;
if
(!
mCamera
.
grab
())
{
Log
.
e
(
TAG
,
"mCamera.grab() failed"
);
break
;
}
bmp
=
processFrame
(
mCamera
);
mFps
.
measure
();
}
if
(
bmp
!=
null
)
{
Canvas
canvas
=
mHolder
.
lockCanvas
();
if
(
canvas
!=
null
)
{
canvas
.
drawColor
(
0
,
android
.
graphics
.
PorterDuff
.
Mode
.
CLEAR
);
canvas
.
drawBitmap
(
bmp
,
(
canvas
.
getWidth
()
-
bmp
.
getWidth
())
/
2
,
(
canvas
.
getHeight
()
-
bmp
.
getHeight
()),
null
);
mFps
.
draw
(
canvas
,
(
canvas
.
getWidth
()
-
bmp
.
getWidth
())
/
2
,
0
);
mHolder
.
unlockCanvasAndPost
(
canvas
);
}
bmp
.
recycle
();
}
}
Log
.
i
(
TAG
,
"Finished processing thread"
);
}
}
\ No newline at end of file
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