Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.db.replaymobile
Commits
9c2ce444
Commit
9c2ce444
authored
Oct 07, 2016
by
Amir Mohammadi
Browse files
Use aggregation for inheritance
parent
8d68a694
Pipeline
#4667
canceled with stages
in 2 minutes and 59 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
bob/db/replaymobile/verificationprotocol.py
View file @
9c2ce444
...
...
@@ -8,6 +8,7 @@ framework). It also implements a kind of hack so that you can run
vulnerability analysis with it. """
from
bob.db.base
import
File
as
BaseFile
from
bob.db.base
import
Database
as
BaseDatabase
from
.query
import
Database
as
LDatabase
...
...
@@ -41,7 +42,7 @@ class File(BaseFile):
return
super
(
File
,
self
).
load
(
directory
,
extension
)
class
Database
(
L
Database
):
class
Database
(
Base
Database
):
"""
Implements verification API for querying Replay Mobile database.
This database loads max_number_of_frames from the video files as
...
...
@@ -51,9 +52,11 @@ class Database(LDatabase):
__doc__
=
__doc__
def
__init__
(
self
,
max_number_of_frames
=
None
):
# call base class constructors to open a session to the database
super
(
Database
,
self
).
__init__
()
# call base class constructors to open a session to the database
self
.
_db
=
LDatabase
()
self
.
max_number_of_frames
=
max_number_of_frames
or
10
# 300 is the number of frames in replay mobile videos
self
.
indices
=
selected_indices
(
300
,
max_number_of_frames
)
...
...
@@ -65,23 +68,13 @@ class Database(LDatabase):
Here I am going to hack and double the number of protocols
with -licit and -spoof. This is done for running vulnerability
analysis"""
names
=
[
p
.
name
+
'-licit'
for
p
in
s
uper
(
Database
,
self
)
.
protocols
()]
names
+=
[
p
.
name
+
'-spoof'
for
p
in
s
uper
(
Database
,
self
)
.
protocols
()]
names
=
[
p
.
name
+
'-licit'
for
p
in
s
elf
.
_db
.
protocols
()]
names
+=
[
p
.
name
+
'-spoof'
for
p
in
s
elf
.
_db
.
protocols
()]
return
names
def
groups
(
self
):
return
self
.
convert_names_to_highlevel
(
super
(
Database
,
self
).
groups
(),
self
.
low_level_group_names
,
self
.
high_level_group_names
)
def
annotations
(
self
,
myfile
):
"""Will return the bounding box annotation of nth frame of the video."""
fn
=
myfile
.
framen
# 10th frame number
annots
=
myfile
.
_f
.
bbx
(
directory
=
self
.
original_directory
)
# bob uses the (y, x) format
topleft
=
(
annots
[
fn
][
2
],
annots
[
fn
][
1
])
bottomright
=
(
annots
[
fn
][
2
]
+
annots
[
fn
][
4
],
annots
[
fn
][
1
]
+
annots
[
fn
][
3
])
annotations
=
{
'topleft'
:
topleft
,
'bottomright'
:
bottomright
}
return
annotations
self
.
_db
.
groups
(),
self
.
low_level_group_names
,
self
.
high_level_group_names
)
def
model_ids_with_protocol
(
self
,
groups
=
None
,
protocol
=
None
,
**
kwargs
):
# since the low-level API does not support verification straight-forward-ly, we improvise.
...
...
@@ -128,7 +121,7 @@ class Database(LDatabase):
purposes
.
append
(
'attack'
)
# now, query the actual Replay database
objects
=
s
uper
(
Database
,
self
)
.
objects
(
groups
=
groups
,
protocol
=
protocol
,
cls
=
purposes
,
clients
=
model_ids
,
**
kwargs
)
objects
=
s
elf
.
_db
.
objects
(
groups
=
groups
,
protocol
=
protocol
,
cls
=
purposes
,
clients
=
model_ids
,
**
kwargs
)
# make sure to return File representation of a file, not the database one
# also make sure you replace client ids with attack
...
...
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