Have ever waited for a lot of time on convert *.jpg output.mpeg and then it told you convert: Delegate failed `"mpeg2encode" "%i" "%o"' .. dahhhh
get mpeg2encode from here http://www.mpeg.org/pub_ftp/mpeg/mssg/mpeg2vidcodec_v12.tar.gz untar, make and you are done!
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Tuesday, October 20, 2009
Wednesday, February 11, 2009
Sunday, January 18, 2009
libf2c.so: undefined reference to `MAIN__'
Alright.. so problems with libf2c with debian, ubuntu, etc, getting too much of libf2c.so: undefined reference to `MAIN__'
ok, just link with the static library "libf2c.a"
sudo rm /usr/lib/libf2c.so && sudo ln -s /usr/lib/libf2c.a /usr/lib/libf2c.so
Done!
ok, just link with the static library "libf2c.a"
sudo rm /usr/lib/libf2c.so && sudo ln -s /usr/lib/libf2c.a /usr/lib/libf2c.so
Done!
Friday, May 9, 2008
OpenCV stuff 0
Hello world,
we'll do opencv cool things running on Linux, as I have no idea how to do any of the stuff with visual studio
we'll start with a very simple example that will draw nice shapes in an image
#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <stdio.h>
#include <l;stdlib.h>
// a simple example that creates an image and fills it up with stuff
int main(int argc, char *argv[])
{
IplImage *img;
int i, j, step, channels, height, width;
uchar *data;
// WxH, depth, channels
img = cvCreateImage(cvSize(640,480), 8, 1);
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels; // which is 1 (gray image)
data = (uchar *)img->imageData;
for(i=0; i < height; i++)
for(j=0; j < width; j++)
data[i*step + j*channels] = (i*i + j*j) % 256;
// create a window
cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
// show the image
cvShowImage("image", img);
// wait for 'q'
while(cvWaitKey(0) != 'q')
;
// destroy the widnow
cvDestroyWindow("image");
// don't forget to release the image
cvReleaseImage(&img);
return 0;
}
Cool... now to compile the opencv program, it is even easier, we'll use gcc here:
gcc `pkg-config --cflags --libs opencv` -o opencvsimple opencvsimple.c
Done!
we'll do opencv cool things running on Linux, as I have no idea how to do any of the stuff with visual studio
we'll start with a very simple example that will draw nice shapes in an image
#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <stdio.h>
#include <l;stdlib.h>
// a simple example that creates an image and fills it up with stuff
int main(int argc, char *argv[])
{
IplImage *img;
int i, j, step, channels, height, width;
uchar *data;
// WxH, depth, channels
img = cvCreateImage(cvSize(640,480), 8, 1);
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels; // which is 1 (gray image)
data = (uchar *)img->imageData;
for(i=0; i < height; i++)
for(j=0; j < width; j++)
data[i*step + j*channels] = (i*i + j*j) % 256;
// create a window
cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
// show the image
cvShowImage("image", img);
// wait for 'q'
while(cvWaitKey(0) != 'q')
;
// destroy the widnow
cvDestroyWindow("image");
// don't forget to release the image
cvReleaseImage(&img);
return 0;
}
Cool... now to compile the opencv program, it is even easier, we'll use gcc here:
gcc `pkg-config --cflags --libs opencv` -o opencvsimple opencvsimple.c
Done!
Monday, January 14, 2008
error: cout is not a member of std
What the ....?
Q:What is wrong with this block of code in a program?
std::cout << "HelloWorld\n";
A:
Q:What is wrong with this block of code in a program?
std::cout << "HelloWorld\n";
A:
#include <iostream>
Saturday, December 29, 2007
Find images of certain size and copy them to some directory
Let us say you wanna find images of width 640 so you copy them to a separate directory for further processing. How can you do that?
Here is one way to do it
First, you have to find out the files with width 640. Second, copy them.
To find out file of certain size you can use the command identify
$ identify 0100.jpg
0100.jpg JPEG 378x251 PseudoClass 256c 9kb
Now, when u do
$ identify*.jpg | grep 640
new_0100-0.jpg[451] JPEG 640x425 PseudoClass 256c 16kb
new_0101-0.jpg[453] JPEG 640x425 PseudoClass 256c 22kb
new_0102-0.jpg[455] JPEG 640x425 PseudoClass 256c 24kb
new_0103-0.jpg[457] JPEG 640x425 PseudoClass 256c 26kb
new_0104-0.jpg[459] JPEG 640x425 PseudoClass 256c 12kb
new_0105-0.jpg[461] JPEG 640x425 PseudoClass 256c 23kb
new_0106-0.jpg[463] JPEG 640x425 PseudoClass 256c 20kb
new_0107-0.jpg[465] JPEG 640x425 PseudoClass 256c 24kb
new_0108-0.jpg[467] JPEG 640x425 PseudoClass 256c 17kb
new_0109-0.jpg[469] JPEG 640x425 PseudoClass 256c 28kb
new_0110-0.jpg[471] JPEG 640x425 PseudoClass 256c 31kb
new_0111-0.jpg[473] JPEG 640x425 PseudoClass 256c 36kb
new_0112-0.jpg[475] JPEG 640x425 PseudoClass 256c 27kb
new_0113-0.jpg[477] JPEG 640x425 PseudoClass 256c 25kb
so we do this and save the output in the file files
identify *.jpg | grep 640 | cut -f 1 -d [ > files
Finally
for i in `cat files`; do cp $i directory_640/; done
Here is one way to do it
First, you have to find out the files with width 640. Second, copy them.
To find out file of certain size you can use the command identify
$ identify 0100.jpg
0100.jpg JPEG 378x251 PseudoClass 256c 9kb
Now, when u do
$ identify*.jpg | grep 640
new_0100-0.jpg[451] JPEG 640x425 PseudoClass 256c 16kb
new_0101-0.jpg[453] JPEG 640x425 PseudoClass 256c 22kb
new_0102-0.jpg[455] JPEG 640x425 PseudoClass 256c 24kb
new_0103-0.jpg[457] JPEG 640x425 PseudoClass 256c 26kb
new_0104-0.jpg[459] JPEG 640x425 PseudoClass 256c 12kb
new_0105-0.jpg[461] JPEG 640x425 PseudoClass 256c 23kb
new_0106-0.jpg[463] JPEG 640x425 PseudoClass 256c 20kb
new_0107-0.jpg[465] JPEG 640x425 PseudoClass 256c 24kb
new_0108-0.jpg[467] JPEG 640x425 PseudoClass 256c 17kb
new_0109-0.jpg[469] JPEG 640x425 PseudoClass 256c 28kb
new_0110-0.jpg[471] JPEG 640x425 PseudoClass 256c 31kb
new_0111-0.jpg[473] JPEG 640x425 PseudoClass 256c 36kb
new_0112-0.jpg[475] JPEG 640x425 PseudoClass 256c 27kb
new_0113-0.jpg[477] JPEG 640x425 PseudoClass 256c 25kb
so we do this and save the output in the file files
identify *.jpg | grep 640 | cut -f 1 -d [ > files
Finally
for i in `cat files`; do cp $i directory_640/; done
Thursday, December 27, 2007
Renaming or changing extension of multiple files at once
In a lot of time you want to rename multiple files at once, or maybe change their extension. My Sony camera names files with the extension .JPG which is really annoying!!! I'd love to have it as .jpg or maybe something else. Further, the camera naming scheme is DSCxxxx.JPG where xxxx is for the number of the image, and I'd like to have some custom name instead. So, how to do this?
First, let us start off with an introduction about file naming and shell scripts. Mass file renaming is a pretty common task among everybody and a lot of people do it in many situations, such as the Sony camera situation, or maybe you have so many files in one directory what you want to rename to something else. Examples of these cases are endless, so let us start with file renaming and some of the available tools to do that without wasting time discussing situations.
The BASH shell provides many useful tools for renaming multiple files. Please note that I'm not claiming that BASH shell is the best. I think that the Z shell might provide more tools, but it is so complex for me :)
One tool you can use in bash to rename multiple files is combining the UNIX command mv with a for loop like this:
for file in .; do mv $file hello; done
well... this is not useful.. in face this is disastrous this will rename all files in the current directory to hello, not only this, but also you'll have one file in that directory called hello. Poor you, nothing left to celebrate, no more old memories and nice moments taken by camera, because you've formatted your memory stick :) So let's not do this at all.
Alright, let's say you just want to rename all files in the current directory to holiday_xxxx.jpg, where xxxx is the serial number for a photo, starting from 0000 up to 9999 (of FFFF if your prefer hex)
Let us do that
#!/bin/bash
prefix="holiday"
i=0
for file in *.jpg; do
num=`printf "%.4d" "$i"`
let "i += 1"
mv $file "$prefix_$num.jpg"
done
And that is it we are done. We can also take the prefix as a command line argument and thus use this script in any place where we want to rename jpg photos:
#!/bin/bash
if [ -z "$1" ]; then
echo "please supply a prefix(name) argument"
exit
fi
prefix="$1"
i=0
for file in *.jpg; do
num=`printf "%.4d" "$i"`
let "i += 1"
mv $file "$prefix_$num.jpg"
done
Cool.. now let's explore another tool.. basename. You can use basename like in situations like this:
nitro$ basename /usr/bin/perl
nitro$ perl
Another useful use is when you supply a suffix to basename like this
nitro$ basename hello.jpg .jpg
nitro$ hello
nitro$ basename hello.jpg jpg
nitro$ hello.
nitro$ basename hello.jpg g
nitro$ hello.jp
So, to lowercase a lot of .JPG file you can do this:
nitro$ for file in *.JPG; do mv $file "`basename $file .JPG`.jpg"; done
in my opinion, the easiest is this one, which is using the built in bash variable substitution
for file in *.JPG; do mv $file ${file/.JPG}.jpg; done
Some good source to look @ http://www.debian-administration.org/articles/150
First, let us start off with an introduction about file naming and shell scripts. Mass file renaming is a pretty common task among everybody and a lot of people do it in many situations, such as the Sony camera situation, or maybe you have so many files in one directory what you want to rename to something else. Examples of these cases are endless, so let us start with file renaming and some of the available tools to do that without wasting time discussing situations.
The BASH shell provides many useful tools for renaming multiple files. Please note that I'm not claiming that BASH shell is the best. I think that the Z shell might provide more tools, but it is so complex for me :)
One tool you can use in bash to rename multiple files is combining the UNIX command mv with a for loop like this:
for file in .; do mv $file hello; done
well... this is not useful.. in face this is disastrous this will rename all files in the current directory to hello, not only this, but also you'll have one file in that directory called hello. Poor you, nothing left to celebrate, no more old memories and nice moments taken by camera, because you've formatted your memory stick :) So let's not do this at all.
Alright, let's say you just want to rename all files in the current directory to holiday_xxxx.jpg, where xxxx is the serial number for a photo, starting from 0000 up to 9999 (of FFFF if your prefer hex)
Let us do that
#!/bin/bash
prefix="holiday"
i=0
for file in *.jpg; do
num=`printf "%.4d" "$i"`
let "i += 1"
mv $file "$prefix_$num.jpg"
done
And that is it we are done. We can also take the prefix as a command line argument and thus use this script in any place where we want to rename jpg photos:
#!/bin/bash
if [ -z "$1" ]; then
echo "please supply a prefix(name) argument"
exit
fi
prefix="$1"
i=0
for file in *.jpg; do
num=`printf "%.4d" "$i"`
let "i += 1"
mv $file "$prefix_$num.jpg"
done
Cool.. now let's explore another tool.. basename. You can use basename like in situations like this:
nitro$ basename /usr/bin/perl
nitro$ perl
Another useful use is when you supply a suffix to basename like this
nitro$ basename hello.jpg .jpg
nitro$ hello
nitro$ basename hello.jpg jpg
nitro$ hello.
nitro$ basename hello.jpg g
nitro$ hello.jp
So, to lowercase a lot of .JPG file you can do this:
nitro$ for file in *.JPG; do mv $file "`basename $file .JPG`.jpg"; done
in my opinion, the easiest is this one, which is using the built in bash variable substitution
for file in *.JPG; do mv $file ${file/.JPG}.jpg; done
Some good source to look @ http://www.debian-administration.org/articles/150
Wednesday, December 26, 2007
Simple Command Line Arguments in BASH
The number of arguments in the command line in BASH scripts is stored in $#, while the list of arguments is stored in $@. You can access arguments by there index. For example, $1 is the first argument in the list and $2 is the second ... etc. Notice that $0 is the name of the file (script file name)
Code example (documentation is left as an exercise for the reader)
--------------------------------------------------------------------
#!/bin/bash
# This code will mv not executable (-x flag is off)
# from src_dir(def=".") to target_dir.
src_dir=''
target_dir=''
if [ -z "$1" ]; then
echo "Usage: `basename $0` [src_dir] target_dir
exit
fi
if [ "$#" == 2 ]; then
if [ ! -d "$1" -o ! -d "$2" ]; then
echo "Error: You must supply directory names on the cmd line"
exit
fi
src_dir=$1
target_dir=$2
else
src_dir="."
target_dir=$1
fi
for file in $src_dir/*
do
if [ ! -x $file ]; then
mv $file $target_dir
fi
done
--------------------------------------------------------------------
Code example (documentation is left as an exercise for the reader)
--------------------------------------------------------------------
#!/bin/bash
# This code will mv not executable (-x flag is off)
# from src_dir(def=".") to target_dir.
src_dir=''
target_dir=''
if [ -z "$1" ]; then
echo "Usage: `basename $0` [src_dir] target_dir
exit
fi
if [ "$#" == 2 ]; then
if [ ! -d "$1" -o ! -d "$2" ]; then
echo "Error: You must supply directory names on the cmd line"
exit
fi
src_dir=$1
target_dir=$2
else
src_dir="."
target_dir=$1
fi
for file in $src_dir/*
do
if [ ! -x $file ]; then
mv $file $target_dir
fi
done
--------------------------------------------------------------------
Monday, December 24, 2007
Bash loops
Section 1.0 If statements
Although costs much in terms of cycles.. we can't live without them...
Here is how you quickly
var="NiTrO"
if [ $var = "NiTro" ]; then
echo $var
else
echo "HelloWorld\n"
fi
Section 1.1 Loops
Let's do some BASH loops.. notice this is BASH not sh :)
a quicky for loop
for img in $(ls | grep *.jpg); do echo $img; done
for i in `seq 0 10`; do echo $i; done
i=0; # no spaces
while [ $i -lt 100 ]; do # a space after [
echo $i
let i=i+1
done
# until -- this will do the same as the previous loop
i=0;
until [ $i -gt 10 ]; do
echo $i
let i=i+1
done
Section 1.2 Logical Operators
we love logical operators, which are those weired things used in tests and conditional statements...
For strings... it is very easy
=, !=, <, >, -z (is null), -n (is not null)
Arithmetic
-lt, -le, -gt, -ge, -eq -ne
Ok i'm bored!! enough for today
Although costs much in terms of cycles.. we can't live without them...
Here is how you quickly
var="NiTrO"
if [ $var = "NiTro" ]; then
echo $var
else
echo "HelloWorld\n"
fi
Section 1.1 Loops
Let's do some BASH loops.. notice this is BASH not sh :)
a quicky for loop
for img in $(ls | grep *.jpg); do echo $img; done
for i in `seq 0 10`; do echo $i; done
i=0; # no spaces
while [ $i -lt 100 ]; do # a space after [
echo $i
let i=i+1
done
# until -- this will do the same as the previous loop
i=0;
until [ $i -gt 10 ]; do
echo $i
let i=i+1
done
Section 1.2 Logical Operators
we love logical operators, which are those weired things used in tests and conditional statements...
For strings... it is very easy
=, !=, <, >, -z (is null), -n (is not null)
Arithmetic
-lt, -le, -gt, -ge, -eq -ne
Ok i'm bored!! enough for today
Sunday, December 23, 2007
Perl loops
Here are some quicky perl loops
for(my $i=0; $i<$limit; $i++) {
print $i;
}
while($i<$limit) {
print "$limit\n";
}
for $i (@array) {
print "$i\n";
}
until($i > 100) {
print $i;
}
for(my $i=0; $i<$limit; $i++) {
print $i;
}
while($i<$limit) {
print "$limit\n";
}
for $i (@array) {
print "$i\n";
}
until($i > 100) {
print $i;
}
Subscribe to:
Posts (Atom)