Recherche avancée

Médias (0)

Mot : - Tags -/tags

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (90)

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

Sur d’autres sites (12896)

  • Matplotlib : ValueError : I/O operation on closed file [duplicate]

    28 septembre 2017, par gopi

    This question is an exact duplicate of :

    %matplotlib inline
    import math,os,sys,numpy as np
    from numpy.random import random
    from matplotlib import pyplot as plt, rcParams, animation, rc
    from __future__ import print_function, division
    from ipywidgets import interact, interactive, fixed
    from ipywidgets.widgets import *
    rc('animation', html='html5')
    rcParams['figure.figsize'] = 3,3
    %precision 4
    np.set_printoptions(precision=4, linewidth=100)

    def lin(a,x,b): return a * x + b

    a = 3.
    b = 8.
    n = 30

    x = random(n)
    y = lin(a,x,b)

    plt.scatter(x,y)

    def sse(y, y_pred): return ((y-y_pred)**2).sum()
    def loss(y, a, x, b): return sse(y, lin(a, x, b))
    def avg_loss(y, a, x, b): return np.sqrt(loss(y, a, x, b)/n)

    a_guess = -1
    b_guess = 1
    avg_loss(y, a_guess, x, b_guess)

    lr = 0.01
    #d[(y-(a*x+b))**2, b] = 2 (y_pred - y)
    #d[(y -(a*x+b)) **2, a] = x * dy/db

    def upd():
       global a_guess, b_guess
       y_pred = lin(a_guess, x, b_guess)
       dydb = 2 * (y_pred - y)
       dyda = x * dydb
       a_guess -= lr*dyda.mean()
       b_guess -= lr*dydb.mean()


    fig = plt.figure(dpi=100, figsize=(5,5))
    plt.scatter(x,y)
    line, = plt.plot(x, lin(a_guess, x, b_guess))
    plt.close()

    def animate(i):
       line.set_ydata(lin(a_guess, x, b_guess))
       for i in range(10): upd()
       return line,


    ani = animation.FuncAnimation(fig, animate, np.arange(0, 40), interval=100)
    ani

    But when I run it I get the following error,

       ValueError Traceback (most recent call last)
    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
       309             method = get_real_method(obj, self.print_method)
       310             if method is not None:
    --> 311                 return method()
       312             return None
       313         else:

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in _repr_html_(self)
      1233         fmt = rcParams['animation.html']
      1234         if fmt == 'html5':
    -> 1235             return self.to_html5_video()
      1236
      1237

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in to_html5_video(self)
      1207                                 bitrate=rcParams['animation.bitrate'],
      1208                                 fps=1000. / self._interval)
    -> 1209                 self.save(f.name, writer=writer)
      1210
      1211             # Now open and base64 encode

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs)
      1061                         # TODO: See if turning off blit is really necessary
      1062                         anim._draw_next_frame(d, blit=False)
    -> 1063                     writer.grab_frame(**savefig_kwargs)
      1064
      1065         # Reconnect signal for first draw if necessary

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/contextlib.pyc in __exit__(self, type, value, traceback)
        33                 value = type()
        34             try:
    ---> 35                 self.gen.throw(type, value, traceback)
        36                 raise RuntimeError("generator didn't stop after throw()")
        37             except StopIteration, exc:

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in saving(self, *args, **kw)
       287             yield self
       288         finally:
    --> 289             self.finish()
       290
       291     def _run(self):

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in finish(self)
       307     def finish(self):
       308         'Finish any processing for writing the movie.'
    --> 309         self.cleanup()
       310
       311     def grab_frame(self, **savefig_kwargs):

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/animation.pyc in cleanup(self)
       346     def cleanup(self):
       347         'Clean-up and collect the process used to write the movie file.'
    --> 348         out, err = self._proc.communicate()
       349         self._frame_sink().close()
       350         verbose.report('MovieWriter -- '

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/subprocess32.pyc in communicate(self, input, timeout)
       925
       926         try:
    --> 927             stdout, stderr = self._communicate(input, endtime, timeout)
       928         finally:
       929             self._communication_started = True

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/subprocess32.pyc in _communicate(self, input, endtime, orig_timeout)
      1711             if _has_poll:
      1712                 stdout, stderr = self._communicate_with_poll(input, endtime,
    -> 1713                                                              orig_timeout)
      1714             else:
      1715                 stdout, stderr = self._communicate_with_select(input, endtime,

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/subprocess32.pyc in _communicate_with_poll(self, input, endtime, orig_timeout)
      1767             select_POLLIN_POLLPRI = select.POLLIN | select.POLLPRI
      1768             if self.stdout:
    -> 1769                 register_and_append(self.stdout, select_POLLIN_POLLPRI)
      1770                 stdout = self._fd2output[self.stdout.fileno()]
      1771             if self.stderr:

    /home/gopinath/Workspace/anaconda3/envs/py27/lib/python2.7/site-packages/subprocess32.pyc in register_and_append(file_obj, eventmask)
      1746             poller = select.poll()
      1747             def register_and_append(file_obj, eventmask):
    -> 1748                 poller.register(file_obj.fileno(), eventmask)
      1749                 self._fd2file[file_obj.fileno()] = file_obj
      1750

    ValueError: I/O operation on closed file

    I almost tried everywhere and I couldn’t find a solution, I tried reinstalling ffmpeg from the sources, moved this file to the folder where I installed ffmpeg and gave a try.

    I’m using python 3.5,
    Ubuntu 16.04
    Anaconda 4.4
    Matplotlib 2.02

    actually this particular course was taught using python 2.7 so I created a virenv installed 2.7 along with all related dependencies. So will it be the problem ?? I mean using python 2.7 on top of 3.5 ?

  • Convert images into video

    24 septembre 2017, par Disha Shukla

    I have some images in the folder. I want to convert all images into videos. But the problem is that when the resolution is different it shows the error. I don’t want to stretch the images in the video. I just want to keep image size as it is. But it shows this error.

    My Command :

    ffmpeg -framerate 1/3 -pattern_type glob -i "images/*.jpg" -i trinity.MP3 -shortest -c:v libx264 -r 30 -vf "scale=iw*sar:ih , pad=max(iw\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2" -aspect 16:9 -pix_fmt yuv420p out.mp4 -y

    Logs :

    [mjpeg @ 0x6b3820] Changeing bps to 8
    Input #0, image2, from 'images/*.jpg':
     Duration: 00:00:24.00, start: 0.000000, bitrate: N/A
       Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 0.33 fps, 0.33 tbr, 0.33 tbn, 0.33 tbc
    [mp3 @ 0x6b4ca0] Estimating duration from bitrate, this may be inaccurate
    Input #1, mp3, from 'trinity.MP3':
     Metadata:
       encoded_by      : Lavf52.9.0
     Duration: 00:09:02.35, start: 0.000000, bitrate: 128 kb/s
       Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    [swscaler @ 0x68a3c0] deprecated pixel format used, make sure you did set range correctly
    [libx264 @ 0x6bada0] using SAR=1/1
    [libx264 @ 0x6bada0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0x6bada0] profile High, level 3.1
    [libx264 @ 0x6bada0] 264 - core 142 r2438 af8e768 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to 'out.mp4':
     Metadata:
       encoder         : Lavf56.25.101
       Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
       Metadata:
         encoder         : Lavc56.26.100 libx264
       Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
       Metadata:
         encoder         : Lavc56.26.100 libfaac
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
     Stream #1:0 -> #0:1 (mp3 (native) -> aac (libfaac))
    Press [q] to stop, [?] for help
    Input stream #0:0 frame changed from size:1280x720 fmt:yuvj420p to size:596x913 fmt:yuvj420p
    [Parsed_pad_1 @ 0x697940] Input area 512:0:1108:913 not within the padded area 0:0:1622:912 or zero-sized
    [Parsed_pad_1 @ 0x697940] Failed to configure input pad on Parsed_pad_1

    Is there any way to keep resolution as it is and make a video of all images ?

  • python cv2 BackgroundSubtractor imshow function error

    16 septembre 2017, par Vincent Yuan

    problem

    I want to detect the motional object in a video, but the cap seems not to read the video. I use conda jupyter and have install the ffmpeg with brew and I use macOS. Still, I am unable to capture the video.

    code :

    import numpy as np
    import cv2
    import time

    cap = cv2.VideoCapture('test.avi')
    time.sleep(2)
    fgbg = cv2.createBackgroundSubtractorKNN(detectShadows=True)

    while(1):
    ret, frame = cap.read()

    fgmask = fgbg.apply(frame)

    cv2.imshow('original',frame)
    cv2.imshow('fg',fgmask)

    k = cv2.waitKey(30) & 0xff
    for c in contours:
           # 获取矩形框边界坐标
           x, y, w, h = cv2.boundingRect(c)
           # 计算矩形框的面积
           area = cv2.contourArea(c)
           if 500 < area < 3000:
               cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)

    cv2.imshow("detection", frame)
    cv2.imshow("back", dilated)


    if k == 27:
       break


    cap.release()
    cv2.destroyAllWindows()

    error

    Couldn’t read video stream from file "test.avi"