Permalink
Browse files

add function to surround faces with a yellow box

  • Loading branch information...
sdpython committed Jan 19, 2018
1 parent 2b26c5d commit 07390522b90bd600b8f6ed3bc4d77bfabaed7350
View
@@ -275,3 +275,5 @@ _doc/notebooks/ateliers/devoxx2018/*.mp3
_doc/notebooks/ateliers/devoxx2018/Untitled.ipynb
_doc/notebooks/ateliers/devoxx2018/example.ipynb
_unittests/ut_faq/courte_audioTEMP_MPY_wvf_snd.mp3
_doc/notebooks/Untitled.ipynb
_doc/notebooks/*.mp4
@@ -15,3 +15,8 @@ Deep Learning
+++++++++++++
.. autosignature:: code_beatrix.art.videodl.video_map_images
Détecteur rapides
+++++++++++++++++
.. autosignature:: code_beatrix.art.videodl.video_map_images_detect
@@ -82,6 +82,7 @@
epkg_dictionary[
'Mary Poppins'] = 'https://fr.wikipedia.org/wiki/Mary_Poppins_(film,_1964)'
epkg_dictionary['moviepy'] = 'https://zulko.github.io/moviepy/'
epkg_dictionary['opencv'] = 'https://opencv.org/'
epkg_dictionary['OpenShot'] = 'https://www.openshot.org/'
epkg_dictionary['pytube'] = 'https://github.com/nficano/pytube'
epkg_dictionary['SciTe'] = 'http://www.scintilla.org/SciTE.html'
@@ -1,3 +1,6 @@
cartoon011.wav - source: http://www.grsites.com/
cartoon026.wav - source: http://www.grsites.com/
mary.mp4 - source: https://www.youtube.com/watch?v=BA-g8YYPKVo
charlie.mp4 - source: https://www.youtube.com/watch?v=n_1apYo6-Ow
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
"""
@brief test log(time=1000s)
Duraction is around a few seconds but the test needs to be run
at the end of the series of unitests as it interferes
with the notebook unittesting (it uses Popen too).
"""
import sys
import os
import unittest
try:
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from skimage.io._plugins.pil_plugin import pil_to_ndarray
from PIL import Image
from src.code_beatrix.art.video_drawing import rectangle
class TestVideoDrawing(ExtTestCase):
def test_rectangle(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_rectangle")
img = os.path.join(temp, '..', 'data', 'img1.jpg')
pil_img = Image.open(img)
skimg = pil_to_ndarray(pil_img)
im1 = skimg.copy().ravel()
rectangle(skimg, (10, 20), (100, 200))
im2 = skimg.copy().ravel()
self.assertTrue(im1.tolist() != im2.tolist())
pil_img2 = Image.fromarray(skimg)
dest = os.path.join(temp, "img_rect.jpg")
pil_img2.save(dest)
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
"""
@brief test log(time=1000s)
Duraction is around a few seconds but the test needs to be run
at the end of the series of unitests as it interferes
with the notebook unittesting (it uses Popen too).
"""
import sys
import os
import unittest
try:
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from src.code_beatrix.art.videodl import video_map_images
from src.code_beatrix.art.video import video_save, video_extract_video, video_save_image
class TestVideoDLFace(ExtTestCase):
def test_modify_avideo_blur(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_videodl_face_blur")
vid = os.path.join(temp, '..', 'data', 'mary.mp4')
vide = video_extract_video(vid, 0, 5 if __name__ == "__main__" else 1)
vid2 = video_map_images(
vide, fps=10, name="detect", progress_bar=__name__ == "__main__", fLOG=fLOG)
exp = os.path.join(temp, "face.mp4")
video_save(vid2, exp)
self.assertExists(exp)
def test_modify_avideo(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_videodl_face_rect")
vid = os.path.join(temp, '..', 'data', 'charlie.mp4')
vide = video_extract_video(vid, 0, 5 if __name__ == "__main__" else 1)
vid2 = video_map_images(
vide, fps=10, name="detect", action="rect", progress_bar=__name__ == "__main__", fLOG=fLOG)
exp = os.path.join(temp, "face.mp4")
self.assertTrue(vid2.make_frame is not None)
video_save_image(vid2, t=1, filename=os.path.join(temp, "img1.jpg"))
im = video_save_image(vid2, t=2)
im.save(os.path.join(temp, "img2.png"))
video_save(vid2, exp, verbose=__name__ == "__main__")
self.assertExists(exp)
if __name__ == "__main__":
unittest.main()
View
@@ -36,6 +36,7 @@
packages = find_packages('src', exclude='src')
package_dir = {k: "src/" + k.replace(".", "/") for k in packages}
package_data = {project_var_name + ".algorithm.data": ["*.txt"],
project_var_name + ".art.data": ["*.xml"],
project_var_name + ".scratchs.example_echiquier": ["*.sb2"],
project_var_name + ".scratchs.example_tri": ["*.sb2"],
project_var_name + ".scratchs.example_pyramide": ["*.sb2"],
No changes.
Oops, something went wrong.

0 comments on commit 0739052

Please sign in to comment.