
Recherche avancée
Médias (91)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
avec chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
sans chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
config chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (61)
-
List of compatible distributions
26 avril 2011, parThe 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 2011Si 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, parLa 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à ObradorI’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 << "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<<"De"<*
std::ofstream fout("MAFD.txt");
if(fout.is_open()==true)
{
//file opened successfully so we are here
std::cout << "File Opened successfully!!!. Writing data from array to file" << std::endl;
for(int i = 0; MAFD[i] != '\0'; i++)
{
fout << MAFD[i]; //writing ith character of array in the file
}
std::cout << "Array data successfully saved into the file test.txt" << std::endl;
}
else //file could not be opened
{
std::cout << "File could not be opened." << 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 NolreneaI 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.


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.

Example :


Original image (Google Drive)


Video Output (Google Drive)


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


Full working code



import cv2
import numpy as np
import random
import rpack
from fractions import Fraction
from math import prod

def resize_guide(image_size, target_area):
 aspect_ratio = Fraction(*image_size).limit_denominator()
 horizontal = aspect_ratio.numerator
 vertical = aspect_ratio.denominator
 unit_length = (target_area/(horizontal*vertical))**.5
 return (int(horizontal*unit_length), int(vertical*unit_length))

fourcc = cv2.VideoWriter_fourcc(*'h264')
FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)

def new_frame():
 return np.ndarray.copy(FRAME)

def center(image):
 frame = new_frame()
 h, w = image.shape[:2]
 yoff = round((1080-h)/2)
 xoff = round((1920-w)/2)
 frame[yoff:yoff+h, xoff:xoff+w] = image
 return frame

def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8, fast_decrement=256):
 image = cv2.imread(file)
 height, width = image.shape[:2]
 assert width*height >= 1920*1080
 video_writer = cv2.VideoWriter(file+'.mp4', fourcc, fps, (1920, 1080))
 fit_height = True
 if height < 1080:
 width = width*1080/height
 image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)
 aspect_ratio = width / height
 zooming_needed = False
 if 4/9 <= aspect_ratio <= 16/9:
 new_width = round(width*1080/height)
 fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)
 zooming_needed = True
 
 elif 16/9 < aspect_ratio <= 32/9:
 new_height = round(height*1920/width)
 fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)
 fit_height = False
 zooming_needed = True
 
 centered = center(fit)
 for i in range(fps):
 video_writer.write(centered)
 if fit_height:
 xoff = round((1920 - new_width)/2)
 while xoff:
 if xoff - pan_increment >= 0:
 xoff -= pan_increment
 else:
 xoff = 0
 frame = new_frame()
 frame[0:1080, xoff:xoff+new_width] = fit
 video_writer.write(frame)
 else:
 yoff = round((1080 - new_height)/2)
 while yoff:
 if yoff - pan_increment >= 0:
 yoff -= pan_increment
 else:
 yoff = 0
 frame = new_frame()
 frame[yoff:yoff+new_height, 0:1920] = fit
 video_writer.write(frame)
 
 if zooming_needed:
 if fit_height:
 width_1, height_1 = new_width, 1080
 else:
 width_1, height_1 = 1920, new_height
 new_area = width_1 * height_1
 original_area = width * height
 area_diff = original_area - new_area
 unit_diff = area_diff / fps
 for i in range(1, fps+1):
 zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area+unit_diff*i), interpolation=cv2.INTER_AREA)
 zheight, zwidth = zoomed.shape[:2]
 zheight = min(zheight, 1080)
 zwidth = min(zwidth, 1920)
 frame = new_frame()
 frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]
 video_writer.write(frame)
 y, x = 0, 0
 completed = False
 while y != height - 1080:
 x = 0
 while x != width - 1920:
 if x + horizontal_increment + 1920 <= width:
 x += horizontal_increment
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 else:
 x = width - 1920
 frame = image[y:y+1080, x:x+1920]
 for i in range(round(fps/3)):
 video_writer.write(frame)
 if y == height - 1080:
 completed = True
 while x != 0:
 if x - fast_decrement - 1920 >= 0:
 x -= fast_decrement
 else:
 x = 0
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 if y + 2160 <= height:
 y += 1080
 else:
 y = height - 1080
 cv2.destroyAllWindows()
 video_writer.release()
 del video_writer



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


Now if I change the last few lines to this :


if y + 2160 <= height:
 y += 1080
 else:
 y = height - 1080
 x = 0
 while x != width - 1920:
 if x + horizontal_increment + 1920 <= width:
 x += horizontal_increment
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 cv2.destroyAllWindows()
 video_writer.release()
 del video_writer



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


OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
---------------------------------------------------------------------------
error Traceback (most recent call last)
 in <module>
----> 1 image_scanning("D:/collages/91f53ebcea2a.png")

 in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)
 122 x += horizontal_increment
 123 frame = image[y:y+1080, x:x+1920]
--> 124 video_writer.write(frame)
 125 cv2.destroyAllWindows()
 126 video_writer.release()

error: Unknown C++ exception from OpenCV code
</module>


(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)


How to get rid of the exception ?


-
Methods For Retaining State
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.