Recherche avancée

Médias (91)

Autres articles (61)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (5243)

  • C++/OpenCV - VideoCapture doesn't work but it worked before with exactly the same code

    5 mars 2015, par Damià Obrador

    I’m trying to write a shot boundary detection algorithm in C++ using OpenCV. After all, I have to say that I have no experience working with OpenCV.

    I have been improving the following code (and I am still in it) during the last two weeks and everything seems the works correctly, not in terms of perfect shot detection, but every line of code did what was expected from it.

    #include <cstdlib>
    #include <opencv2></opencv2>opencv.hpp>
    #include <opencv2></opencv2>core/core.hpp>
    #include <opencv2></opencv2>video/background_segm.hpp>
    #include <opencv2></opencv2>highgui/highgui.hpp>
    #include <iostream>
    #include <opencv2></opencv2>imgproc/imgproc.hpp>
    #include
    #include <istream>
    #include <fstream>
    using namespace cv;



    int main(){

       VideoCapture capture("vdevendetta.mp4");
       if ( !capture.isOpened() )
        {
            std::cout &lt;&lt; "Cannot open the video file";
            return -1;
        }
       int numFrames=capture.get(CV_CAP_PROP_FRAME_COUNT);
       bool SB_counter=false;
       Mat currentFrame;
       Mat frame;
       Mat fore;
       Mat back;
       vector<mat> frames;
       FileStorage file;
       FileStorage file2;
       Mat prev_Y;
       Mat channels[3];
       for(int i=0;i>currentFrame;
               frame=currentFrame.clone();
               cvtColor(frame,frame,CV_BGR2YUV);
               split( frame, channels );
               prev_Y=channels[0];
               SB_counter=false;
           }
           else
           {
               capture>>currentFrame;
               frame=currentFrame.clone();
               Mat channels[3];
               cvtColor(frame,frame,CV_BGR2YUV);
               split( frame, channels );
               Mat curr_Y=channels[0];
               channels[0]=prev_Y;
               prev_Y=curr_Y;
               merge(channels,3,frame);
               cvtColor(frame,frame,CV_Luv2BGR);
               cvtColor(frame,frame,CV_BGR2GRAY);
               frames.push_back(frame);
           }

       }

       vector<double> MAFDs;
       vector<double> MAFD;
       vector<double> aux;
       double min;
       double min2;

       for(int j=1;j14)
           {
               std::cout&lt;&lt;"De"&lt;*
       std::ofstream fout("MAFD.txt");
       if(fout.is_open()==true)
       {
         //file opened successfully so we are here
         std::cout &lt;&lt; "File Opened successfully!!!. Writing data from array to file" &lt;&lt; std::endl;

           for(int i = 0; MAFD[i] != '\0'; i++)
           {
           fout &lt;&lt; MAFD[i]; //writing ith character of array in the file
           }
         std::cout &lt;&lt; "Array data successfully saved into the file test.txt" &lt;&lt; std::endl;
       }
       else //file could not be opened
       {
           std::cout &lt;&lt; "File could not be opened." &lt;&lt; std::endl;
       }*/
       return 0;
    }
    </double></double></double></mat></fstream></istream></iostream></cstdlib>

    Three days ago I had an strange problem. The line :

    VideoCapture capture("vdevendetta.mp4");

    stopped working. I spent many hours looking for the solution but nothing seems to repair it. After reading everything related with OpenCV, VideoCapture and ffmpeg that I found on internet I decided to reinstall everything taking care of each detail, but it still didn’t work. Finally I solved it changing the line with this other one :

    VideoCapture capture("/home/damia/Documentos/Universitat/ARA/PAEAV/workspace_cpp/SBD/src/vdevendetta.mp4");

    I did not know why this solved it because the video is in the same directory than the program, but I continued working because everything seemed correct.
    Today I had the same problem again on the new line.
    The terminal doesn’t show any error comment (exceptuating "Cannot open the video file", obviously) but the code doesn’t work again.

    I’m using Ubuntu 14.04 LTS, OpenCV 2.4.9 and Eclipse.

    I think if someone test the code it will run correctly, but I would like to know if there is something I have no taking into account.

    Thank you very match.

  • Python cv2 script that scans a giant image to a video. Raises error : Unknown C++ exception from OpenCV code

    26 avril 2022, par Nolrenea

    I wrote a script that scans a giant image to make a video. Normally I just post my scripts straight to my Code Review account, but this script is ugly, needs to be refactored, implements only horizontal scrolling and contains a bug that I can't get rid of.

    &#xA;

    It is working but not perfect, I can't get the last line at the bottom of the image, with height of image_height % 1080. If I ignore it, the code is working fine, if I try to fix it, it throws exceptions.

    &#xA;

    Example :

    &#xA;

    Original image (Google Drive)

    &#xA;

    Video Output (Google Drive)

    &#xA;

    As you can see from the video, everything is working properly except the fact that I can't get the bottom line.

    &#xA;

    Full working code

    &#xA;


    &#xA;
    import cv2&#xA;import numpy as np&#xA;import random&#xA;import rpack&#xA;from fractions import Fraction&#xA;from math import prod&#xA;&#xA;def resize_guide(image_size, target_area):&#xA;    aspect_ratio = Fraction(*image_size).limit_denominator()&#xA;    horizontal = aspect_ratio.numerator&#xA;    vertical = aspect_ratio.denominator&#xA;    unit_length = (target_area/(horizontal*vertical))**.5&#xA;    return (int(horizontal*unit_length), int(vertical*unit_length))&#xA;&#xA;fourcc = cv2.VideoWriter_fourcc(*&#x27;h264&#x27;)&#xA;FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)&#xA;&#xA;def new_frame():&#xA;    return np.ndarray.copy(FRAME)&#xA;&#xA;def center(image):&#xA;    frame = new_frame()&#xA;    h, w = image.shape[:2]&#xA;    yoff = round((1080-h)/2)&#xA;    xoff = round((1920-w)/2)&#xA;    frame[yoff:yoff&#x2B;h, xoff:xoff&#x2B;w] = image&#xA;    return frame&#xA;&#xA;def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8, fast_decrement=256):&#xA;    image = cv2.imread(file)&#xA;    height, width = image.shape[:2]&#xA;    assert width*height >= 1920*1080&#xA;    video_writer = cv2.VideoWriter(file&#x2B;&#x27;.mp4&#x27;, fourcc, fps, (1920, 1080))&#xA;    fit_height = True&#xA;    if height &lt; 1080:&#xA;        width = width*1080/height&#xA;        image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)&#xA;    aspect_ratio = width / height&#xA;    zooming_needed = False&#xA;    if 4/9 &lt;= aspect_ratio &lt;= 16/9:&#xA;        new_width = round(width*1080/height)&#xA;        fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)&#xA;        zooming_needed = True&#xA;    &#xA;    elif 16/9 &lt; aspect_ratio &lt;= 32/9:&#xA;        new_height = round(height*1920/width)&#xA;        fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)&#xA;        fit_height = False&#xA;        zooming_needed = True&#xA;    &#xA;    centered = center(fit)&#xA;    for i in range(fps):&#xA;        video_writer.write(centered)&#xA;    if fit_height:&#xA;        xoff = round((1920 - new_width)/2)&#xA;        while xoff:&#xA;            if xoff - pan_increment >= 0:&#xA;                xoff -= pan_increment&#xA;            else:&#xA;                xoff = 0&#xA;            frame = new_frame()&#xA;            frame[0:1080, xoff:xoff&#x2B;new_width] = fit&#xA;            video_writer.write(frame)&#xA;    else:&#xA;        yoff = round((1080 - new_height)/2)&#xA;        while yoff:&#xA;            if yoff - pan_increment >= 0:&#xA;                yoff -= pan_increment&#xA;            else:&#xA;                yoff = 0&#xA;            frame = new_frame()&#xA;            frame[yoff:yoff&#x2B;new_height, 0:1920] = fit&#xA;            video_writer.write(frame)&#xA;    &#xA;    if zooming_needed:&#xA;        if fit_height:&#xA;            width_1, height_1 = new_width, 1080&#xA;        else:&#xA;            width_1, height_1 = 1920, new_height&#xA;        new_area = width_1 * height_1&#xA;        original_area = width * height&#xA;        area_diff = original_area - new_area&#xA;        unit_diff = area_diff / fps&#xA;        for i in range(1, fps&#x2B;1):&#xA;            zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area&#x2B;unit_diff*i), interpolation=cv2.INTER_AREA)&#xA;            zheight, zwidth = zoomed.shape[:2]&#xA;            zheight = min(zheight, 1080)&#xA;            zwidth = min(zwidth, 1920)&#xA;            frame = new_frame()&#xA;            frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]&#xA;            video_writer.write(frame)&#xA;    y, x = 0, 0&#xA;    completed = False&#xA;    while y != height - 1080:&#xA;        x = 0&#xA;        while x != width - 1920:&#xA;            if x &#x2B; horizontal_increment &#x2B; 1920 &lt;= width:&#xA;                x &#x2B;= horizontal_increment&#xA;                frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                video_writer.write(frame)&#xA;            else:&#xA;                x = width - 1920&#xA;                frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                for i in range(round(fps/3)):&#xA;                    video_writer.write(frame)&#xA;                if y == height - 1080:&#xA;                    completed = True&#xA;        while x != 0:&#xA;            if x - fast_decrement - 1920 >= 0:&#xA;                x -= fast_decrement&#xA;            else:&#xA;                x = 0&#xA;            frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;            video_writer.write(frame)&#xA;        if y &#x2B; 2160 &lt;= height:&#xA;            y &#x2B;= 1080&#xA;        else:&#xA;            y = height - 1080&#xA;    cv2.destroyAllWindows()&#xA;    video_writer.release()&#xA;    del video_writer&#xA;

    &#xA;

    The above the the code needed to produce the example video. It is working but the bottom line is missing.

    &#xA;

    Now if I change the last few lines to this :

    &#xA;

            if y &#x2B; 2160 &lt;= height:&#xA;            y &#x2B;= 1080&#xA;        else:&#xA;            y = height - 1080&#xA;            x = 0&#xA;            while x != width - 1920:&#xA;                if x &#x2B; horizontal_increment &#x2B; 1920 &lt;= width:&#xA;                    x &#x2B;= horizontal_increment&#xA;                    frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;                    video_writer.write(frame)&#xA;    cv2.destroyAllWindows()&#xA;    video_writer.release()&#xA;    del video_writer&#xA;

    &#xA;

    I expect it to include the bottom line, but it just throws exceptions instead :

    &#xA;

    OpenCV: FFMPEG: tag 0x34363268/&#x27;h264&#x27; is not supported with codec id 27 and format &#x27;mp4 / MP4 (MPEG-4 Part 14)&#x27;&#xA;OpenCV: FFMPEG: fallback to use tag 0x31637661/&#x27;avc1&#x27;&#xA;---------------------------------------------------------------------------&#xA;error                                     Traceback (most recent call last)&#xA; in <module>&#xA;----> 1 image_scanning("D:/collages/91f53ebcea2a.png")&#xA;&#xA; in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)&#xA;    122                     x &#x2B;= horizontal_increment&#xA;    123                     frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;--> 124                     video_writer.write(frame)&#xA;    125     cv2.destroyAllWindows()&#xA;    126     video_writer.release()&#xA;&#xA;error: Unknown C&#x2B;&#x2B; exception from OpenCV code&#xA;</module>

    &#xA;

    (If you can't get the example code working I can't help you, but I am using Python 3.9.10 x64 on Windows 10, and I have this file : "C :\Windows\System32\openh264-1.8.0-win64.dll", the '.avi' format generates video files with Gibibytes (binary unit, not SI Gigabyte) of size)

    &#xA;

    How to get rid of the exception ?

    &#xA;

  • Methods For Retaining State

    26 décembre 2011, par Multimedia Mike — General, evernote, organization

    I jump around between projects. A lot. Over the years, I have employed various methods for retaining state or context as I switch to a different project. Here’s a quick survey and a general classification of their effectiveness.

    Good

    • Evernote : This is a cloud-based note-taking service that has a web client, Mac and Windows clients, and clients for just about ever mobile platform out there. I have an account and access it via the web interface as as the Windows, iOS, and Android clients. I really like it.


    Okay

    • Series of text files : I have been doing this for a very long time. I have many little note-filled directories here and there that are consistently migrated to new machines but generally forgotten about. This isn’t a terrible method but can be unwieldy when you work on lots of different machines. I’m still tracking down all these directories and importing them into Evernote.

    Bad

    • Layout of desktop windows : I have a habit of working on one project in a set of windows on one desktop space and another project in a second set of windows in another space, etc. Oh, this makes me shudder just thinking about it, mostly because of living in constant fear of a power failure or some other inadvertent reset (darn you, default config’d Windows Update) that wipes the state clean (sure, all of the work might have been saved, but I was relying on those windows to be set up in just the right manner to remind me of all the things I was working on). These days, I force myself to reboot at least once a week so I can’t get too deep into this habit. When it’s time to change projects, I write up exactly what I was doing and where I left off and stick it in Evernote.
    • Open browser windows : I guess it’s common to have many, many tabs open in one’s web browser in this day and age. Like many, I use open tabs as a stack of items to read. The state problem comes when a few of the open tabs represent TODO items. Then I start living in fear that the browser might crash or be restarted in an unexpected way and I struggle to recall what 3-5 important TODO items were that I had opened in separate tabs (on top of a stack of less important items). Again, I try to shut down the browser frequently in order to break this tendency. TODO items are better filed in Evernote.
    • Unsaved data in a text editor : Okay, this is just sloppy on my part, shoving temporary data into a text editor window thinking it’s supremely ephemeral. The problem comes when it’s linked to one of the many tasks on my desktop that might be bumped down a few priority levels ; when finally returning to the context-free data, I’m at a loss to explain what it’s for. Evernote gets it, once more, with a more thorough description of what was going on.
    • Email inbox : I make an effort to ensure that my email inbox has the fewest number of messages possible. Once things are dealt with, they get filed away elsewhere. This implies that things in my inbox require action. Some things have a habit of hanging around, though. Longer items now get described in better detail and filed away in Evernote.
    • Classic paper : Thanks to Derek in the comments for reminding me of this one. Paper is a reliable standby but it can get unwieldy when Post-It Notes litter your work area. Further, it can be problematic when you have multiple physical work areas.
    • Shell history : Another method I rely on entirely too often. This is when I count on a recipe of command line incantations living on in the history buffer of my Unix shell (generally Bash). What sequence of git commands allowed me to do XYZ ? Let’s check the shell history– I sure hope it’s still in there.

    Conclusion
    I guess what I’m trying to say here is that I really like Evernote. If you have similar troubles with retaining state, try it out. I hear there are many other services similar to it with slightly varying feature sets (people rave about Microsoft OneNote). So there are plenty of options and something out there is surely a fit.

    Evernote has a free tier and a premium tier. For my meager note-taking needs, I don’t come anywhere close to the free tier’s limit but I decided to pay for a premium subscription simply because I feel like I derive so much value from the service.

    One downside, however, is that I seem to be doing a lot less blogging since I got on Evernote earlier this year (though it is where I author most of these posts nowadays ; I especially like that I have a notebook labeled “Posted” whose incrementing count reminds me that I am getting some stuff out there). I originally started this blog as a sort of technical journal in order to organize notes and projects in a central location. It’s strange to think that if Evernote existed in 2005, I might never have had a reason to start this blog.