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
1e2880b7
Commit
1e2880b7
authored
Jul 18, 2011
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: fix in Mat::put methods, general improvements
parent
bcac8769
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Mat.cpp
modules/java/src/cpp/Mat.cpp
+7
-5
No files found.
modules/java/src/cpp/Mat.cpp
View file @
1e2880b7
...
...
@@ -79,11 +79,12 @@ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nClone
// unlike other nPut()-s this one (with double[]) should convert input values to correct type
#define PUT_ITEM(T, R, C) for(int ch=0; ch<me->channels() && count>0; ch++,count--) *((T*)me->ptr(R, C)+ch) = cv::saturate_cast<T>(*(src+ch))
JNIEXPORT
jint
JNICALL
Java_org_opencv_Mat_nPutD
(
JNIEnv
*
env
,
jclass
cls
,
jlong
self
,
jint
row
,
jint
col
,
jint
count
,
jdoubleArray
vals
)
{
cv
::
Mat
*
me
=
(
cv
::
Mat
*
)
self
;
if
(
!
self
)
return
0
;
// no native object behind
if
(
!
me
||
!
me
->
data
)
return
0
;
// no native object behind
if
(
me
->
rows
<=
row
||
me
->
cols
<=
col
)
return
0
;
// indexes out of range
int
rest
=
((
me
->
rows
-
row
)
*
me
->
cols
-
col
)
*
me
->
channels
();
...
...
@@ -135,6 +136,7 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count,
if
(
!
m
)
return
0
;
if
(
!
buff
)
return
0
;
count
*=
sizeof
(
T
);
int
rest
=
((
m
->
rows
-
row
)
*
m
->
cols
-
col
)
*
m
->
channels
()
*
sizeof
(
T
);
if
(
count
>
rest
)
count
=
rest
;
int
res
=
count
;
...
...
@@ -183,7 +185,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_Mat_nPutS
{
cv
::
Mat
*
me
=
(
cv
::
Mat
*
)
self
;
if
(
!
self
)
return
0
;
// no native object behind
if
(
me
->
depth
()
!=
CV_
8U
&&
me
->
depth
()
!=
CV_8
S
)
return
0
;
// incompatible type
if
(
me
->
depth
()
!=
CV_
16U
&&
me
->
depth
()
!=
CV_16
S
)
return
0
;
// incompatible type
if
(
me
->
rows
<=
row
||
me
->
cols
<=
col
)
return
0
;
// indexes out of range
char
*
values
=
(
char
*
)
env
->
GetPrimitiveArrayCritical
(
vals
,
0
);
...
...
@@ -197,7 +199,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_Mat_nPutI
{
cv
::
Mat
*
me
=
(
cv
::
Mat
*
)
self
;
if
(
!
self
)
return
0
;
// no native object behind
if
(
me
->
depth
()
!=
CV_
8U
&&
me
->
depth
()
!=
CV_8
S
)
return
0
;
// incompatible type
if
(
me
->
depth
()
!=
CV_
32
S
)
return
0
;
// incompatible type
if
(
me
->
rows
<=
row
||
me
->
cols
<=
col
)
return
0
;
// indexes out of range
char
*
values
=
(
char
*
)
env
->
GetPrimitiveArrayCritical
(
vals
,
0
);
...
...
@@ -211,7 +213,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_Mat_nPutF
{
cv
::
Mat
*
me
=
(
cv
::
Mat
*
)
self
;
if
(
!
self
)
return
0
;
// no native object behind
if
(
me
->
depth
()
!=
CV_
8U
&&
me
->
depth
()
!=
CV_8S
)
return
0
;
// incompatible type
if
(
me
->
depth
()
!=
CV_
32F
)
return
0
;
// incompatible type
if
(
me
->
rows
<=
row
||
me
->
cols
<=
col
)
return
0
;
// indexes out of range
char
*
values
=
(
char
*
)
env
->
GetPrimitiveArrayCritical
(
vals
,
0
);
...
...
@@ -231,7 +233,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
if
(
!
m
)
return
0
;
if
(
!
buff
)
return
0
;
count
*=
sizeof
(
T
);
//This change is required, checked TODO: recheck for non-continious case
count
*=
sizeof
(
T
);
int
rest
=
((
m
->
rows
-
row
)
*
m
->
cols
-
col
)
*
m
->
channels
()
*
sizeof
(
T
);
if
(
count
>
rest
)
count
=
rest
;
int
res
=
count
;
...
...
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