vendredi 14 décembre 2012

Got a brand new printer HP Officejet 4500 wireless. Scanner and printer are working properly without any adjustment (Ubuntu 10.10) :-)

jeudi 25 octobre 2012

global variables in C



the "not bad" way to define global variables in C


#ifdef FOO_LIBRARY_C 
#define GLOBAL_PREFIX 
#else 
#define GLOBAL_PREFIX extern 
#endif 

GLOBAL_PREFIX int a,b,c
 


http://stackoverflow.com/questions/2868651/including-c-header-file-with-lots-of-global-variables

lundi 15 octobre 2012

conversion HD uyvy -> RGB

                i=0;
                for (y=0;y<image.rows;y++)
                {
                    uchar* ptr_cv= (uchar *)( image.ptr() + image.channels()*y * image.cols);   
                    for (x=0;x<image.cols/2;x++)
                    {
                        U = pData[i]-128.0;
                        YY1 = 1.164*(pData[i+1]-16);
                        V = pData[i+2]-128.0;
                        YY2 = 1.164*(pData[i+3]-16);
                        i+=4;

                        B=YY1          + 1.793*U;
                        G=YY1 - 0.534*V- 0.213*U;
                        R=YY1 + 2.115*V;
                        if (R<0) R=0;if (G<0) G=0;if (B<0) B=0;
                        if (R>255) R=255;if (G>255) G=255;if (B>255) B=255;
                        j=2*image.channels()*x;
                        ptr_cv[j]  = (unsigned char)B;
                        ptr_cv[j+1]= (unsigned char)G;
                        ptr_cv[j+2]= (unsigned char)R;
                        B=YY2          + 1.793*U;
                        G=YY2 - 0.534*V- 0.213*U;
                        R=YY2 + 2.115*V;
                        if (R<0) R=0;if (G<0) G=0;if (B<0) B=0;
                        if (R>255) R=255;if (G>255) G=255;if (B>255) B=255;
                        ptr_cv[j+3]  = (unsigned char)B;
                        ptr_cv[j+4]= (unsigned char)G;
                        ptr_cv[j+5]= (unsigned char)R;

                    }
                }

jeudi 26 juillet 2012

Not satisfied with Unity on Ubuntu 12

With Unity  on Ubuntu 12, the user interface changed so much that you drastically need to change your habits. Is it worth spending time for what looks like a commercial move toward tablets? For my own work, I started to use Mint, whose look and feel is closer to Ubuntu 10.

dimanche 10 juin 2012

encodage DVD

 mencoder -oac mp3lame -lameopts mode=2:cbr:br=128:vol=0 -dvd-device /media/DVD_VIDEO dvd://0 -aid 128 -sid 1 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:autoaspect -o toto.avi

mercredi 6 juin 2012

Make system clone

Download  Clonezilla.iso
Create LiveCD
Boot LiveCD
Use english version (French version is not understandable!)
Choose clone partition (here sda1 vers sdb1)
Fortunately or unfortunately there was  a MBR on the second disk 
A message tells that the grub2 was automatically fixed (?)
Halt system
Remove first disk
The second disk boots normally
First problem UUID of boot partition is the same as in the first disk (possible mix up if the two disks are present)


uuidgen -t
1eff00c0-affc-11e1-8145-1c6f6531b911
sudo tune2fs -U 1eff00c0-affc-11e1-8145-1c6f6531b911 /dev/sda1



This corrects the problem
Change the /etc/fstab  file
UUID=1eff00c0-affc-11e1-8145-1c6f6531b911 /  ext4    errors=remount-ro 0       1


here you need to update grub!!!
mount /dev/sda1 /mnt 
sudo grub-install --root-directory=/mnt /dev/sda



Second Problem The partition table is not readable by  Gparted also the sfdisk command reads the partition table normally (?)
 sfdisk -l
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=100304896, Id=83, bootable
/dev/sda2 : start=100306944, size=1853216768, Id= 5
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0

Download fixparts
Use Fixparts /dev/sda
p (prints the partition table)Disk size is 156301488 sectors (74.5 GiB)
MBR disk identifier: 0x000744BD
MBR partitions:

                                                   Can Be   Can Be
Number  Boot  Start Sector   End Sector   Status   Logical  Primary   Code
   1      *           2048    100306943   primary     Y        Y      0x83

W (writes MBR)
Gparted mow recognizes the partition table
Create swap and additional work partitions



vendredi 1 juin 2012

select timeout

Problem:
Under some unclear conditions, but particularly if CPU load is too high, I get "select timeout" messages apparently due to video acquisition (v4l2)
Essai Workaround : 
-create or modify file /etc/modprobe.d/uvcvideoconf, insert line
options uvcvideo nodrop=1 trace=15 quirks=0x102 timeout=3000
-type sudo rmmod uvcvideo; sudo  modprobe uvcvideo
-reduce the number of cpu used by the program (here 2 instead of 4):
taskset -c 1,2 my_program


Works better but still fails after a while


Apparently this a bug of usb driver as far as I know unresolved  to date (06/12) even with recent kernels. Tried to close and reopen webcam every 3mn