Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
File Recovery RecycleBin
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
wanglei
File Recovery RecycleBin
Commits
4e7f8c4d
Commit
4e7f8c4d
authored
Jul 30, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
b2bd8bb9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
29 deletions
+92
-29
build.gradle
app/build.gradle
+0
-1
SimilarHelper.kt
...va/com/base/filerecoveryrecyclebin/utils/SimilarHelper.kt
+63
-28
office-google-services.json
office-google-services.json
+29
-0
No files found.
app/build.gradle
View file @
4e7f8c4d
...
...
@@ -82,7 +82,6 @@ dependencies {
//图片处理
implementation
'org.opencv:opencv:4.10.0'
implementation
(
"org.opencv:opencv:4.10.0"
)
//网络
implementation
group:
'com.google.code.gson'
,
name:
'gson'
,
version:
'2.10.1'
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/utils/SimilarHelper.kt
View file @
4e7f8c4d
...
...
@@ -36,8 +36,9 @@ object SimilarHelper {
// LogEx.logDebug(TAG, "compareItem=$compareItem")
if
(
item
.
path
!=
compareItem
.
path
)
{
val
percent
=
opencvCompareSimilar
(
item
.
path
,
compareItem
.
path
)
if
(
percent
>
98.5
)
{
// val percent = opencvCompareSimilar(item.path, compareItem.path)
val
percent
=
similarPercent
(
File
(
item
.
path
),
File
(
compareItem
.
path
))
if
(
percent
>
60
)
{
if
(
result
[
item
.
path
]
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"item=$item"
)
result
[
item
.
path
]
=
arrayListOf
()
...
...
@@ -62,37 +63,71 @@ object SimilarHelper {
}
// private fun similarPercent(srcFile: File, compareFile: File): Int {
// var similarityScore: Double = 0.00
// try {
// val bitmap1 = BitmapFactory.decodeFile(srcFile.absolutePath)
// val bitmap2 = BitmapFactory.decodeFile(compareFile.absolutePath)
//
// if (bitmap1.width != bitmap2.width || bitmap1.height != bitmap2.height) {
// return 0 // 如果尺寸不同,则直接返回0
// }
//
// var totalDifference = 0L
// for (x in 0 until bitmap1.width) {
// for (y in 0 until bitmap1.height) {
// val pixel1 = bitmap1.getPixel(x, y)
// val pixel2 = bitmap2.getPixel(x, y)
// val redDifference = (pixel1 shr 16 and 0xff) - (pixel2 shr 16 and 0xff)
// val greenDifference = (pixel1 shr 8 and 0xff) - (pixel2 shr 8 and 0xff)
// val blueDifference = (pixel1 and 0xff) - (pixel2 and 0xff)
// totalDifference += (redDifference * redDifference + greenDifference * greenDifference + blueDifference * blueDifference)
// }
// }
//
// // 计算相似度得分
// val maxDifference = bitmap1.width * bitmap1.height * 3 * 255 * 255
// similarityScore = (1 - totalDifference.toDouble() / maxDifference) * 100
//
// } catch (e: Exception) {
// e.printStackTrace()
// }
//
// // 将相似度得分四舍五入到整数
// return similarityScore.toInt().coerceIn(0, 100)
// }
private
fun
similarPercent
(
srcFile
:
File
,
compareFile
:
File
):
Int
{
var
similarityScore
:
Double
=
0.00
try
{
val
bitmap1
=
BitmapFactory
.
decodeFile
(
srcFile
.
absolutePath
)
val
bitmap2
=
BitmapFactory
.
decodeFile
(
compareFile
.
absolutePath
)
if
(
bitmap1
.
width
!=
bitmap2
.
width
||
bitmap1
.
height
!=
bitmap2
.
height
)
{
return
0
// 如果尺寸不同,则直接返回0
}
val
width
=
bitmap1
.
width
val
height
=
bitmap1
.
height
val
maxDifference
=
width
*
height
*
3
*
255
*
255
var
totalDifference
=
0L
for
(
x
in
0
until
bitmap1
.
width
)
{
for
(
y
in
0
until
bitmap1
.
height
)
{
val
pixel1
=
bitmap1
.
getPixel
(
x
,
y
)
val
pixel2
=
bitmap2
.
getPixel
(
x
,
y
)
val
redDifference
=
(
pixel1
shr
16
and
0
xff
)
-
(
pixel2
shr
16
and
0
xff
)
val
greenDifference
=
(
pixel1
shr
8
and
0
xff
)
-
(
pixel2
shr
8
and
0
xff
)
val
blueDifference
=
(
pixel1
and
0
xff
)
-
(
pixel2
and
0
xff
)
totalDifference
+=
(
redDifference
*
redDifference
+
greenDifference
*
greenDifference
+
blueDifference
*
blueDifference
)
}
val
pixel1
=
IntArray
(
1
)
val
pixel2
=
IntArray
(
1
)
for
(
x
in
0
until
width
)
{
for
(
y
in
0
until
height
)
{
bitmap1
.
getPixel
(
x
,
y
)
bitmap2
.
getPixel
(
x
,
y
)
val
red1
=
pixel1
[
0
]
shr
16
and
0
xff
val
green1
=
pixel1
[
0
]
shr
8
and
0
xff
val
blue1
=
pixel1
[
0
]
and
0
xff
val
red2
=
pixel2
[
0
]
shr
16
and
0
xff
val
green2
=
pixel2
[
0
]
shr
8
and
0
xff
val
blue2
=
pixel2
[
0
]
and
0
xff
val
redDiff
=
(
red1
-
red2
)
*
(
red1
-
red2
)
val
greenDiff
=
(
green1
-
green2
)
*
(
green1
-
green2
)
val
blueDiff
=
(
blue1
-
blue2
)
*
(
blue1
-
blue2
)
totalDifference
+=
(
redDiff
+
greenDiff
+
blueDiff
)
}
// 计算相似度得分
val
maxDifference
=
bitmap1
.
width
*
bitmap1
.
height
*
3
*
255
*
255
similarityScore
=
(
1
-
totalDifference
.
toDouble
()
/
maxDifference
)
*
100
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
// 将相似度得分四舍五入到整数
val
similarityScore
=
(
1
-
totalDifference
.
toDouble
()
/
maxDifference
)
*
100
return
similarityScore
.
toInt
().
coerceIn
(
0
,
100
)
}
...
...
office-google-services.json
0 → 100644
View file @
4e7f8c4d
{
"project_info"
:
{
"project_number"
:
"944507974954"
,
"project_id"
:
"dumpster-photo-recovery"
,
"storage_bucket"
:
"dumpster-photo-recovery.appspot.com"
},
"client"
:
[
{
"client_info"
:
{
"mobilesdk_app_id"
:
"1:944507974954:android:1309986ccc55e242589a53"
,
"android_client_info"
:
{
"package_name"
:
"com.baloota.photorecyclebin.awm.sp"
}
},
"oauth_client"
:
[],
"api_key"
:
[
{
"current_key"
:
"AIzaSyDBejd5HFvww_CVve-aFYRBjR-d6XwIBFA"
}
],
"services"
:
{
"appinvite_service"
:
{
"other_platform_oauth_client"
:
[]
}
}
}
],
"configuration_version"
:
"1"
}
\ 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