Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (99)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

Sur d’autres sites (13678)

  • How to Convert 16:9 Video to 9:16 Ratio While Ensuring Speaker Presence in Frame ?

    28 avril 2024, par shreesha

    I am tried so many time to figure out the problem in detecting the face and also it's not so smooth enough to like other tools out there.

    


    So basically I am using python and Yolo in this project but I want the person who is talking and who the ROI (region of interest) is.

    


    Here is the code :

    


    from ultralytics import YOLO
from ultralytics.engine.results import Results
from moviepy.editor import VideoFileClip, concatenate_videoclips
from moviepy.video.fx.crop import crop

# Load the YOLOv8 model
model = YOLO("yolov8n.pt")

# Load the input video
clip = VideoFileClip("short_test.mp4")

tacked_clips = []

for frame_no, frame in enumerate(clip.iter_frames()):
    # Process the frame
    results: list[Results] = model(frame)

    # Get the bounding box of the main object
    if results[0].boxes:
        objects = results[0].boxes
        main_obj = max(
            objects, key=lambda x: x.conf
        )  # Assuming the first detected object is the main one

        x1, y1, x2, y2 = [int(val) for val in main_obj.xyxy[0].tolist()]

        # Calculate the crop region based on the object's position and the target aspect ratio
        w, h = clip.size
        new_w = int(h * 9 / 16)
        new_h = h

        x_center = x2 - x1
        y_center = y2 - y1

        # Adjust x_center and y_center if they would cause the crop region to exceed the bounds
        if x_center + (new_w / 2) > w:
            x_center -= x_center + (new_w / 2) - w
        elif x_center - (new_w / 2) < 0:
            x_center += abs(x_center - (new_w / 2))

        if y_center + (new_h / 2) > h:
            y_center -= y_center + (new_h / 2) - h
        elif y_center - (new_h / 2) < 0:
            y_center += abs(y_center - (new_h / 2))

        # Create a subclip for the current frame
        start_time = frame_no / clip.fps
        end_time = (frame_no + 1) / clip.fps
        subclip = clip.subclip(start_time, end_time)

        # Apply cropping using MoviePy
        cropped_clip = crop(
            subclip, x_center=x_center, y_center=y_center, width=new_w, height=new_h
        )

        tacked_clips.append(cropped_clip)

reframed_clip = concatenate_videoclips(tacked_clips, method="compose")
reframed_clip.write_videofile("output_video.mp4")


    


    So basically I want to fix the face detection with ROI detection where it can detect the face and make that face and the body on to the frame and making sure that the speaker who is speaking is brought to the frame

    


  • FFmpegFrameGrabber and FFmpegFrameRecorder Audio Issue

    20 août 2015, par Sheheryar Chagani

    I am compress an existing camera recorded video using FFmpegframerecorder and ffmpegFrameGrabber.

    The issue is that its audio is not occurring after compression.

    Please note that I am using googlecode.javacv along with javacpp and armeabi in lib folder.

    Below is the code which I have used.

    public void compressVideo(String filePath)

       FrameGrabber grabber = new FFmpegFrameGrabber(filePath);
       grabber.start();
       fileoutput = filePath.replace("trimmed", "compressed");
       // recorder.setAudioCodec(grabber.get);
       FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(fileoutput, 480,
               480, grabber.getAudioChannels());
       recorder.setFrameRate(grabber.getFrameRate());
       recorder.setSampleRate(grabber.getSampleRate());
       recorder.setSampleFormat(grabber.getSampleFormat());
       recorder.setFormat(grabber.getFormat());
       // recorder.setPixelFormat(grabber.getPixelFormat());

       recorder.start();
       Frame frame;
       int count = 0;
       while ((frame = grabber.grabFrame()) != null) {
           if (frame.image != null) {
               publishProgress(count);
               count++;
               IplImage rotateImage = rotate(frame.image, 90);
               IplImage cropImage = resizeImage(rotateImage, 480, 480, true);
               frame.image = cropImage;
               recorder.record(frame);
               if (rotateImage != null)
                   opencv_core.cvReleaseImage(rotateImage);
               if (cropImage != null)
                   opencv_core.cvReleaseImage(cropImage);
           } else {
               recorder.record(frame);
           }

       }
       recorder.stop();
       grabber.stop();
       recorder.release();
       grabber.release();
    }

    IplImage resizeImage(IplImage origImg, int newWidth, int newHeight,
           boolean keepAspectRatio) {

       IplImage outImg;
       int origWidth = 0;
       int origHeight = 0;
       if (origImg != null) {
           origWidth = origImg.width();
           origHeight = origImg.height();
       }
       if (newWidth <= 0 || newHeight <= 0 || origImg == null
               || origWidth <= 0 || origHeight <= 0) {
           // cerr << "ERROR: Bad desired image size of " << newWidth
           // << "x" << newHeight << " in resizeImage().\n";
           return null;
       }

       if (keepAspectRatio) {
           // Resize the image without changing its aspect ratio,
           // by cropping off the edges and enlarging the middle section.
           CvRect r;
           // input aspect ratio
           float origAspect = (origWidth / (float) origHeight);
           // output aspect ratio
           float newAspect = (newWidth / (float) newHeight);
           // crop width to be origHeight * newAspect
           if (origAspect > newAspect) {
               int tw = (origHeight * newWidth) / newHeight;
               // System.out.println((origWidth - tw) / 2+" "+)
               r = opencv_core.cvRect((origWidth - tw) / 2, 0, tw, origHeight);
           } else { // crop height to be origWidth / newAspect
               int th = (origWidth * newHeight) / newWidth;
               r = opencv_core.cvRect(0, (origHeight - th) / 2, origWidth, th);
           }
           IplImage croppedImg = cropImage(origImg, r);

           // Call this function again, with the new aspect ratio image.
           // Will do a scaled image resize with the correct aspect ratio.
           outImg = resizeImage(croppedImg, newWidth, newHeight, false);
           opencv_core.cvReleaseImage(croppedImg);

       } else {

           // Scale the image to the new dimensions,
           // even if the aspect ratio will be changed.
           outImg = opencv_core.cvCreateImage(
                   opencv_core.cvSize(newWidth, newHeight), origImg.depth(),
                   origImg.nChannels());
           if (newWidth > origImg.width() && newHeight > origImg.height()) {
               // Make the image larger
               opencv_core.cvResetImageROI((IplImage) origImg);
               // CV_INTER_LINEAR: good at enlarging.
               // CV_INTER_CUBIC: good at enlarging.
               cvResize(origImg, outImg, CV_INTER_LINEAR);
           } else {
               // Make the image smaller
               opencv_core.cvResetImageROI((IplImage) origImg);
               // CV_INTER_AREA: good at shrinking (decimation) only.
               cvResize(origImg, outImg, CV_INTER_AREA);
           }

       }
       return outImg;
    }

    // Returns a new image that is a cropped version (rectangular cut-out)
    // of the original image.
    IplImage cropImage(IplImage img, CvRect region) {
       IplImage imageCropped;
       opencv_core.CvSize size = new CvSize();

       if (img.width() <= 0 || img.height() <= 0 || region.width() <= 0
               || region.height() <= 0) {
           // cerr << "ERROR in cropImage(): invalid dimensions." << endl;
           return null;
       }

       if (img.depth() != opencv_core.IPL_DEPTH_8U) {
           // cerr << "ERROR in cropImage(): image depth is not 8." << endl;
           return null;
       }

       // Set the desired region of interest.
       opencv_core.cvSetImageROI((IplImage) img, region);
       // Copy region of interest into a new iplImage and return it.
       size.width(region.width());
       size.height(region.height());
       imageCropped = opencv_core.cvCreateImage(size,
               opencv_core.IPL_DEPTH_8U, img.nChannels());
       opencv_core.cvCopy(img, imageCropped); // Copy just the region.

       return imageCropped;
    }

    public IplImage rotate(IplImage image, double angle) {
       IplImage copy = opencv_core.cvCloneImage(image);

       IplImage rotatedImage = opencv_core.cvCreateImage(
               opencv_core.cvGetSize(copy), copy.depth(), copy.nChannels());
       CvMat mapMatrix = opencv_core.cvCreateMat(2, 3, opencv_core.CV_32FC1);

       // Define Mid Point
       CvPoint2D32f centerPoint = new CvPoint2D32f();
       centerPoint.x(copy.width() / 2);
       centerPoint.y(copy.height() / 2);

       // Get Rotational Matrix
       opencv_imgproc.cv2DRotationMatrix(centerPoint, angle, 1.0, mapMatrix);

       // Rotate the Image
       opencv_imgproc.cvWarpAffine(copy, rotatedImage, mapMatrix,
               opencv_imgproc.CV_INTER_CUBIC
                       + opencv_imgproc.CV_WARP_FILL_OUTLIERS,
               opencv_core.cvScalarAll(170));
       opencv_core.cvReleaseImage(copy);
       opencv_core.cvReleaseMat(mapMatrix);
       return rotatedImage;
    }

    I am rotating the video frame and then resizing the frame image.

    The code was working fine 3 days ago but not suddenly it started messing up.

  • avcodec/libzvbi-teletextdec : fix txt_default_region limits

    9 juin 2020, par Marton Balint
    avcodec/libzvbi-teletextdec : fix txt_default_region limits
    

    Max region ID is 87. Also the region affects not only the G0 charset but G2 and
    the national subset as well.

    Signed-off-by : Marton Balint <cus@passwd.hu>

    • [DH] doc/decoders.texi
    • [DH] libavcodec/libzvbi-teletextdec.c