Sunday, January 30, 2011

opcv code3

Maxing out (saturating) only the S and V parts of an HSV image
int main()
{
  IplImage* img = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\airplane.jpg" );
 for( int y=0; y<img->height; y++ ) {
    uchar* ptr = (uchar*) (
      img->imageData + y * img->widthStep
    );
    for( int x=0; x<img->width; x++ ) {
      ptr[3*x+1] = 255;
      ptr[3*x+2] = 255;
    }
  }
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage( "Example1", img );
    cvWaitKey(0);
cvReleaseImage( &img );
}
--------------------------------------------------------------------------------

#include <cv.h>
#include <stdafx.h>
#include <highgui.h>
void my_mouse_callback(
   int event, int x, int y, int flags, void* param
);
CvRect box;
bool drawing_box = false;
void draw_box( IplImage* img, CvRect rect ) {
  cvRectangle (
    img,
    cvPoint(box.x,box.y),
    cvPoint(box.x+box.width,box.y+box.height),
    cvScalar(0xff,0x00,0x00)    /* red */
  );
}
int main( int argc, char* argv[] ) {
  box = cvRect(-1,-1,0,0);
  IplImage* image = cvCreateImage(
    cvSize(200,200),
    IPL_DEPTH_8U,
    3
  );
  //cvZero( image );
  IplImage* temp = cvCloneImage( image );
  cvNamedWindow( "Box Example" );
  cvSetMouseCallback(
    "Box Example",
    my_mouse_callback,
    (void*) image//change to temp will earse square after drawing
  );
  while( 1 ) { //drawing process on temp, but drawn on image
    cvCopy( image, temp );
    if( drawing_box ) draw_box( temp, box );
    cvShowImage( "Box Example", temp );
    if( cvWaitKey( 15 )==27 ) break;
  }
 
  cvReleaseImage( &image );
  cvReleaseImage( &temp );
  cvDestroyWindow( "Box Example" );
}
void my_mouse_callback(
   int event, int x, int y, int flags, void* param
) {
  IplImage* image = (IplImage*) param;
  switch( event ) {
    case CV_EVENT_MOUSEMOVE: {
      if( drawing_box ) {
        box.width  = x-box.x;
        box.height = y-box.y;
      }
    }
    break;
    case CV_EVENT_LBUTTONDOWN: {
      drawing_box = true;
      box = cvRect(x, y, 0, 0);
    }
    break;
    case CV_EVENT_LBUTTONUP: {
      drawing_box = false;
      if(box.width<0) {
        box.x+=box.width;
        box.width *=-1;
      }
      if(box.height<0) {
        box.y+=box.height;
        box.height*=-1;
      }
      draw_box(image, box);
    }
    break;
  }
}

-------------------------------------------------------------------------

consulate-general of people's republic of china

http://calgary.china-consulate.org/chn/lsfw/hzlx/t224885.htm

oversample increase bandwidth

#include <math.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
 int xn=0, N = 250;
 double x[N],y[3*N];
 string filename,outfilename;
   ifstream instream;
  
   cout<<"file"<<endl;
 cin>>filename;                        
 instream.open(filename.c_str());
 cout <<"successful"<<endl;

while(xn != N)
{
 instream >> x[xn];
 cout << "x"<<xn << " = " << x[xn] << endl;
 xn++;
 }
for(xn=0;xn!=N-1;xn++)
{
 y[xn]=x[xn];
 y[xn+1]=0.3333*x[xn]+0.6666*x[xn+1];
 y[xn+2]=0.6666*x[xn]+0.3333*x[xn+1];
 }

cout<<"outfile"<<endl;
cin>>outfilename;
ofstream outfile(outfilename.c_str());
for(xn=0;xn!=N-1;xn++)
{
 outfile<<0.01*xn<<" "<<y[xn]<<endl;
 outfile<<0.01*(xn+0.33333)<<" "<<y[xn+1]<<endl;
 outfile<<0.01*(xn+0.66666)<<" "<<y[xn+2]<<endl;
 }



cout<<"done"<<endl;
return 0;
 }

 

Friday, January 28, 2011

opcv code2

1.  Each slide is presented for a duration of T where T is settable from 0.5 seconds to 5 seconds with a slide bar that is in the viewer window. 
2.  Slides are shown in endless loop such that after the last slide has been presented the first slide is shown again. 
3.  There must be a gradual transition between showing successive slides as shown in the timing diagram below:

#include <cv.h>
#include <stdafx.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int        g_slider_position = 0;
CvCapture* g_capture         = NULL;
void onTrackbarSlide(int pos) {
}

int main( ) {
    IplImage* src1 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right01.jpg" );
    IplImage* src2 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right02.jpg" );
    IplImage* src3 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right03.jpg" );
    IplImage* src4 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right04.jpg" );
    IplImage* src5 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right05.jpg" );
    IplImage* src6 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right06.jpg" );
    IplImage* src7 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right07.jpg" );
    IplImage* src8 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right08.jpg" );
    IplImage* src9 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right09.jpg" );
    IplImage* src10 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right11.jpg" );
 IplImage* src[] ={src1,src2,src3,src4,src5,src6,src7,src8,src9,src10};
 IplImage* dst = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right01.jpg" );
 cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvCreateTrackbar(
     "T",
     "Example1",
     &g_slider_position,
     5,
     onTrackbarSlide
      );
 for(int b=0; ;b++)
 {
  if(b==9){// transition from last slide to the first one
   for(double a=1;a>=0;)
   {  
    cvAddWeighted(src10,a,src1,(1-a),0,dst);
    cvShowImage( "Example1", dst );
    cvWaitKey(10);
    a = a - 0.01; 
   }
   b=0;
   cvWaitKey(1000*g_slider_position+1);}

  for(double a=1;a>=0;)//gradual transition
  {  
   cvAddWeighted(src[b],a,src[b+1],(1-a),0,dst);
   cvShowImage( "Example1", dst );
   cvWaitKey(10);
   a = a - 0.01; 
  }
    cvWaitKey(1000*g_slider_position+1);//lenth of displaying a picture
 }
    cvWaitKey(0);
 cvReleaseImage( src );
 cvReleaseImage( &dst );
    cvDestroyWindow( "Example1" );
}  

opcv code 1

copy an image
#include <cv.h>
#include <stdafx.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int main( int argc, char** argv ) {
    IplImage* img = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\airplane.jpg" );
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage( "Example1", img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
}
-------------------------------------------------------------------------------
displaying a video
int main( int argc, char** argv ) {
    cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
    CvCapture* capture = cvCreateFileCapture( "C:\\ENEL\\OpenCV2.1\\samples\\c\\tree.avi" );
    IplImage* frame;
    while(1) {
        frame = cvQueryFrame( capture );
        if( !frame ) break;
        cvShowImage( "Example2", frame );
        char c = cvWaitKey(33);    //control displaying speed
        if( c == 27 ) break;
    }
    cvReleaseCapture( &capture );
    cvDestroyWindow( "Example2" );
}
-------------------------------------------------------------------------------
add a slider bar
int        g_slider_position = 0;
CvCapture* g_capture         = NULL;
void onTrackbarSlide(int pos) {
    cvSetCaptureProperty(
        g_capture,
        CV_CAP_PROP_POS_FRAMES,
        pos
    );
}
int main( int argc, char** argv ) {
    cvNamedWindow( "Example3", CV_WINDOW_AUTOSIZE );
    g_capture = cvCreateFileCapture( "C:\\ENEL\\OpenCV2.1\\samples\\c\\tree.avi" );
    int frames = (int) cvGetCaptureProperty(
        g_capture,
        CV_CAP_PROP_FRAME_COUNT
    );
    if( frames!= 0 ) {
      cvCreateTrackbar(
          "Position",
          "Example3",
          &g_slider_position,
          frames,
          onTrackbarSlide
      );
    }

    IplImage* frame;
    while(1) {
        frame = cvQueryFrame( g_capture );
        if( !frame ) break;
        cvShowImage( "Example3", frame );
        char c = cvWaitKey(1000);
        if( c == 27 ) break;
    }
    cvReleaseCapture( &g_capture );
    cvDestroyWindow( "Example3" );
    return(0);
}
-------------------------------------------------------------------------
Using ImageROI to increment all of the pixels in a region

int main(int argc, char** argv)
{
    IplImage* src;
    if( (src=cvLoadImage("C:\\ENEL\\OpenCV2.1\\samples\\c\\airplane.jpg",1)) != 0 )
    {
        int x = 10;
        int y = 10;
        int width = 100;
        int height = 100;
        int add = 500;
        cvSetImageROI(src, cvRect(x,y,width,height));
        cvAddS(src, cvScalar(add),src);
        cvResetImageROI(src);
        cvNamedWindow( "Roi_Add", 1 );
        cvShowImage( "Roi_Add", src );
        cvWaitKey();
    }
    return 0;
}
--------------------------------------------------------------
webcam capture
int main()
{
 CvCapture* capture;
    capture = cvCreateCameraCapture(0);

 while(1)
 {
     IplImage* img = cvQueryFrame(capture);
     cvShowImage( "autosize image", img );
  cvShowImage( "scalable image", img );
  if(cvWaitKey(10) == 27)
   break;
 }
}
----------------------------------------------------------------------------

Thursday, January 27, 2011

DFT matlab & gcc


matlab

fs=[ ];
Ys=abs(fft(Yt));
plot(fs,Ys);




fs = 1/t
------------------------------------------------------------------------------------
gcc

#include <math.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
 int k = 0,n = 0,xn=0, N = 250;
 double x[N],y[N],r[N],i[N],real=0,imagin=0,PI=3.1415926;
 string filename,outfilename;
   ifstream instream;
  
   cout<<"file"<<endl;
 cin>>filename;                        
 instream.open(filename.c_str());
 cout <<"successful"<<endl;

while(xn != N)
{
 instream >> x[xn];
 cout << "x"<<xn << " = " << x[xn] << endl;
 xn++;
 }
for(n=0;n!=N;n++)
{
 for(k=0;k!=N;k++)
 {
  r[k] = x[k]*sin(2*PI*k*n/N);
  i[k] = x[k]*cos(2*PI*k*n/N);
  real = real + r[k];
  cout<<"r "<<k<<"= "<<r[k]<<endl;
  imagin=imagin+i[k];
  cout<<"i "<<k<<"= "<<i[k]<<endl;
 }
 cout<<"real "<<n<<"= "<<real<<endl;
 cout<<"imagin"<<n<<"= "<<imagin<<endl;
 y[n]=sqrt(real*real+imagin*imagin);
 cout<<"y "<<n<<"= "<<y[n]<<"----------------------------"<<endl;
 }

cout<<"outfile"<<endl;
cin>>outfilename;
ofstream outfile(outfilename.c_str());
for(xn=0;xn!=N;xn++)
{
 outfile<<100/(xn+1)<<" "<<y[xn]<<endl;
 }

cout<<"done"<<endl;
return 0;
 }


-------------------------------------------------------------------------------------------------
fs=[
100.0000
50.0000
33.3333
25.0000
20.0000
16.6667
14.2857
12.5000
11.1111
10.0000
9.0909
8.3333
7.6923
7.1429
6.6667
6.2500
5.8824
5.5556
5.2632
5.0000
4.7619
4.5455
4.3478
4.1667
4.0000
3.8462
3.7037
3.5714
3.4483
3.3333
3.2258
3.1250
3.0303
2.9412
2.8571
2.7778
2.7027
2.6316
2.5641
2.5000
2.4390
2.3810
2.3256
2.2727
2.2222
2.1739
2.1277
2.0833
2.0408
2.0000
1.9608
1.9231
1.8868
1.8519
1.8182
1.7857
1.7544
1.7241
1.6949
1.6667
1.6393
1.6129
1.5873
1.5625
1.5385
1.5152
1.4925
1.4706
1.4493
1.4286
1.4085
1.3889
1.3699
1.3514
1.3333
1.3158
1.2987
1.2821
1.2658
1.2500
1.2346
1.2195
1.2048
1.1905
1.1765
1.1628
1.1494
1.1364
1.1236
1.1111
1.0989
1.0870
1.0753
1.0638
1.0526
1.0417
1.0309
1.0204
1.0101
1.0000
0.9901
0.9804
0.9709
0.9615
0.9524
0.9434
0.9346
0.9259
0.9174
0.9091
0.9009
0.8929
0.8850
0.8772
0.8696
0.8621
0.8547
0.8475
0.8403
0.8333
0.8264
0.8197
0.8130
0.8065
0.8000
0.7937
0.7874
0.7813
0.7752
0.7692
0.7634
0.7576
0.7519
0.7463
0.7407
0.7353
0.7299
0.7246
0.7194
0.7143
0.7092
0.7042
0.6993
0.6944
0.6897
0.6849
0.6803
0.6757
0.6711
0.6667
0.6623
0.6579
0.6536
0.6494
0.6452
0.6410
0.6369
0.6329
0.6289
0.6250
0.6211
0.6173
0.6135
0.6098
0.6061
0.6024
0.5988
0.5952
0.5917
0.5882
0.5848
0.5814
0.5780
0.5747
0.5714
0.5682
0.5650
0.5618
0.5587
0.5556
0.5525
0.5495
0.5464
0.5435
0.5405
0.5376
0.5348
0.5319
0.5291
0.5263
0.5236
0.5208
0.5181
0.5155
0.5128
0.5102
0.5076
0.5051
0.5025
0.5000
0.4975
0.4950
0.4926
0.4902
0.4878
0.4854
0.4831
0.4808
0.4785
0.4762
0.4739
0.4717
0.4695
0.4673
0.4651
0.4630
0.4608
0.4587
0.4566
0.4545
0.4525
0.4505
0.4484
0.4464
0.4444
0.4425
0.4405
0.4386
0.4367
0.4348
0.4329
0.4310
0.4292
0.4274
0.4255
0.4237
0.4219
0.4202
0.4184
0.4167
0.4149
0.4132
0.4115
0.4098
0.4082
0.4065
0.4049
0.4032
0.4016
0.4000
]

Yt=[0.03
-0.02
0.035
-0.015
0.04
-0.01
0.045
-0.005
0.05
0.0
0.055
0.005
0.06
0.01
0.065
0.015
0.07
0.02
0.08
0.03
0.09
0.04
0.1
0.07
0.09
0.04
0.08
0.03
0.07
0.02
0.06
0.01
0.055
0.005
0.05
0.0
0.04
-0.01
0.03
-0.02
0.02
-0.03
0.02
-0.03
0.02
-0.04
0
-0.05
-0.02
-0.07
-0.05
-0.1
0.05
0.25
0.45
0.55
0.67
1
0.65
0.4
0.3
0.15
0
-0.05
-0.15
-0.21
-0.27
-0.25
-0.22
-0.1
0
0
-0.03
0.02
-0.01
0.04
-0.01
0.04
-0.01
0.04
-0.05
0.045
0.0
0.05
0.05
0.0
0.055
0.005
0.06
0.01
0.08
0.03
0.15
0.1
0.175
0.125
0.18
0.13
0.185
0.135
0.2
0.19
0.14
0.16
0.11
0.14
0.09
0.12
0.07
0.1
0.05
0.08
0.03
0.05
0
0.025
-0.025
0.025
-0.025
0.025
-0.025
0.03
-0.02
0.03
-0.02
0.035
-0.015
0.035
-0.015
0.035
-0.015
0.035
-0.015
0.03
-0.02
0.03
-0.02
0.03
-0.02
0.025
0.03
-0.02
0.035
-0.015
0.04
-0.01
0.045
-0.005
0.05
0.0
0.055
0.005
0.06
0.01
0.065
0.015
0.07
0.02
0.08
0.03
0.09
0.04
0.1
0.07
0.09
0.04
0.08
0.03
0.07
0.02
0.06
0.01
0.055
0.005
0.05
0.0
0.04
-0.01
0.03
-0.02
0.02
-0.03
0.02
-0.03
0.02
-0.04
0
-0.05
-0.02
-0.07
-0.05
-0.1
0.05
0.25
0.45
0.55
0.67
1
0.65
0.4
0.3
0.15
0
-0.05
-0.15
-0.21
-0.27
-0.25
-0.22
-0.1
0
0
-0.03
0.02
-0.01
0.04
-0.01
0.04
-0.01
0.04
-0.05
0.045
0.0
0.05
0.05
0.0
0.055
0.005
0.06
0.01
0.08
0.03
0.15
0.1
0.175
0.125
0.18
0.13
0.185
0.135
0.2
0.19
0.14
0.16
0.11
0.14
0.09
0.12
0.07
0.02
]

iron ring

TO ALL 4TH/5TH YEAR STUDENTS



Hello Graduating Students,



It's time to start thinking about your long-awaited graduation! Please use
this checklist for everything related to graduation and Iron Ring! This
message is long, but please read it and keep a copy of this email to make
sure you don't forget any important steps. There is also a fabulous list of
FAQ questions at the bottom.



Step 1) Apply to Graduate on Peoplesoft



- The deadline to apply to graduate is February 1st. If you haven't done
this yet, log on now! - Make sure that your name is correct, because this is
how it will be printed on your degree. Contact the convocation office if you
require changes.



Step 2) Sign up for Iron Ring Ceremony (April 2) and find out your Ring Size
in the Undgergrad Office



- The sign up for Iron Ring is in the Undergrad office (they will send out
an email with deadline dates).  Do this ASAP!! The next ceremony isn't until
November, so you really don't want to miss this one.

- The Undergrad Office will give you an APEGGA package with further details
about the ceremony, and a registration sheet that you must bring with you to
the Iron Ring Workshop.

- Your APEGGA Member-In-Training registration and your ring are FREE if you
attend the workshop/ceremony. If you do not attend, you have to pay.

- If you have a family member who is a professional engineer with 15 years
experience, they may be able to present your iron ring to you at the
ceremony.

- Please consult your APEGGA workshop package for further details.



Step 3) Buy your tickets for the Graduation Banquet (banquet is on April 2,
the same day as the Iron Ring Ceremony)

- Ticket prices have not been determined as of yet, but will likely be
roughly $60. Cash or cheques accepted. Tickets will go on sale March 28th.



Step 4) Submit your nominations for ESS Student Awards and Professor of the
Year Awards

- Do you know a student or a professor who is deserving of an award? If so,
submit a nomination! - Nomination forms will be available at
www.ess.ucalgary.ca. (DETAILS TO FOLLOW)

- These awards will be given out at the Graduation Banquet on April 2nd



Step 5) Get your Grad Photos Taken

- Final session of pictures is being taken from Jan 31-Feb 4th. Sign up
sheets are available in ESS (ENE 132)



Step 6) Submit your photos for the yearbook!

- Do you have good photos from Engg Week or engineering life in general from
the last few years that you think would look great in the yearbook? And all
graduating students receive a free yearbook. There are two easy and
convenient ways to submit pictures:

Wednesday, January 26, 2011

complex calculation with exel

Microsoft Excel has the capability to do complex calculations , but it is necessary to install
a set of Add-Ins called Analysis ToolPack.  To do this with a spreadsheet open, go to Tools,
select Add-Ins, click on the box to the left of Analysis ToolPack, and click OK.
This installs a set of functions for complex and engineering calculations.  These can be
found in the Excel Help index under "Engineering Functions" and include

COMPLEX(_,_,"j"), which makes a complex number a+bj from the values in two cells
IMABS(_), which calculates the magnitude of a complex number
IMARGUMENT(_), which calculates the radian angle of a complex number
IMSUM(_,_), which calculates the complex sum of two complex numbers
IMSUB(_,_), which calculates the complex difference of two complex numbers
IMPRODUCT(_,_), which calculates the complex product of two complex numbers
IMDIV(_,_), which calculates the complex quotient of two complex numbers
Also useful are
DEGREES(_), which converts a radian angle to degrees
RADIANS(_), which converts a degree angle to radians
(_COS(_)), which calculates the real part of a complex number's magnitude and angle
(_SIN(_)), which calculates the imaginary part of a complex number's magnitude and angle
IMREAL(_), which calculates the real part of a complex number a+bj
IMAGINARY(_), which calculates the imaginary part of a complex number a+bj
1
  http://www.maxim-ic.com/appnotes.cfm/appnote_number/1947/ln/en
http://www.chem.mtu.edu/~tbco/cm416/freqexcel.html

Thursday, January 20, 2011

sanitorysocial8

sanitorysocial8@yahoo.ca


docs: proe










linux commands create directory & file

< Creating directories >

Creating a new, empty directory is very easy. You use the mkdir command:
$ mkdir dir1
That's it. It's really that easy!

< Removing directories >

There are two commands you can use for removing directories. If the directory is empty, you can use rmdir:
$ rmdir dir1
You can use rmdir only if the directory is empty. If you want to remove a directory with all its contents, you can use rm with the -r option. The -r option tells rm to remove a directory recursively:
$ rm -r dir1
It goes without saying that you can cause a lot of trouble with rm -r if you're not careful! In some cases it might be a good thing to use the -i option when deleting a directory with its contents so that you'd be prompted before each file in the directory gets deleted:
$ rm -ir dir1

< Copying and moving directories >

For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you've already tried to copy a directory with cp, you've probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means "copy recursively":
$ cp -r dir1 dir2
The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1.
When renaming directories, you use the mv command exactly the same way as with files:
$ mv dir1 dir2
When dealing with directories, mv works a bit like cp does. If dir2 doesn't exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.

Create a file in Linux using cat command.


Below is an example to create using cat command to create file.

[root@fedora ~]# cat > create-linux-file.txt
this is my file
Create file in linux using cat command
my filename is create-linux-file.txt

[root@fedora ~]# ls
anaconda-ks.cfg Desktop install.log.syslog
create-linux-file.txt install-fedora.log X.txt
[root@fedora ~]#

[root@fedora ~]# cat create-linux-file.txt
this is my file
Create file in linux using cat command
my file name is create-linux-file.txt
[root@fedora ~]#

   The command above will create a file called linux-command-list and to finish your work press Ctrl+d after the line break (press Enter key after your last line of text) to denote the end of file.  Please note that the standard symbol of redirection ' > ' (greater than) sign is necessary to create a new file.  The ls command use on above example is to verify the existence of the newly created file.

Appends text to file using cat command.


  The example below show the cat command with the appends ' >> ' redirection symbol to add more text to the file that we create earlier (create-linux-file.txt file).

[root@fedora ~]# cat >> create-linux-file.txt
this is the line appends to create-linux-file.txt
this is an example on using redirection to appends text

[root@fedora ~]# ls
[root@fedora ~]# cat create-linux-file.txt
this is my file
Create file in linux using cat command
my file name is create-linux-file.txt
this is the line appends to create-linux-file.txt
this is an example on using redirection to appends text
[root@fedora ~]#

To finish your work press Ctrl+d after the line break.  The next shell prompt suppose to appear after you press Ctrl+d key.

Display file contents on Linux system using cat command.


  There is many way to display file contents in Linux system, one of the easiest and simplest way to display the file contents is using cat command.

Note: Remember that we already create text file name create-linux-file.txt, now the procedure below show how to use cat command to display the file contents to the screen.

[root@fedora ~]# cat create-linux-file.txt
this is my file
Create file in linux using cat command
my file name is create-linux-file.txt
this is the line appends to create-linux-file.txt
this is an example on using redirection to appends text
[root@fedora ~]#

Note:
To display the file contents you don't need any redirections sign (no '>' or '>>'), just issue the cat command and the filename of file that you wish to display.
All the file contents display immediately after you issue the command.
The file contents display on the line after the command, and the file content finish before the next shell prompt.

There is many options for the cat command that you can experiment with.

[root@fedora ~]# cat -n create-linux-file.txt
    1   this is my file
    2   Create file in linux using cat command
    3   my file name is create-linux-file.txt
    4   this is the line appends to create-linux-file.txt
    5   this is an example on using redirection to appends text
[root@fedora ~]#

The cat command with the '-n' option will display the file contents with the numbered output lines on the screen.

The following are some of the flags and arguments that can be used for the cat command:

-A, --show-all   =>   equivalent to -vET
-b, --number-nonblank   =>   number nonblank output lines
-e   =>   equivalent to -vE
-E, --show-ends   =>   display $ at end of each line
-n, --number   =>   number all output lines
-s, --squeeze-blank   =>   never more than one single blank line
-t   =>   equivalent to -vT
-T, --show-tabs   =>   display TAB characters as ^I
-u   =>   (ignored)
-v, --show-nonprinting   =>   use ^ and M- notation, except for LFD and TAB
    --help   =>   display this help and exit
    --version   =>   output version information and exit

NAME:
cat - concatenate files and print on the standard output
Usage: cat [OPTION] [FILE]...

For more in formations on using cat command:
[root@fedora ~]# info cat
[root@fedora ~]# man cat
[root@fedora ~]# cat --help

sanitorysocial7

sanitorysocial7@yahoo.ca


docs: proe

Tuesday, January 18, 2011

关于 Withdraw (redemption) and Transfer.

除了 Home Buyer Plan and Longlife Learn Plan 外,尽量不要对 RRSP 进行Withdraw,那样的话算作当年的收入而且还失去了这些额度。所以如果要转换您的管理机构的话,只可以做Transfer,或者重新开个新的户头。
但可以对 TFSA进行Withdraw,缺点是当年不可以买回,但以后可以,因此没有失去额度。并且,如果不完全取出,可以节省 Transfer fee. 比如,如果在 A 机构有 $5000的TFSA,可以在年底取出$4900(留 $100)在那里防止关闭账户导致的费用(当然如果没有这笔费用则可以全部取出),然后在 B 机构开新的账户;不过这样做,您TFSA的总投入量没有增加;如果要做大化的投入的话,可以重新开新的账户。
总之,Transfer的话有费用,但可以最大化 TFSA贡献额度。Withdraw 没有费用,但取出的资金当年不可以再放回

如何合理利用RRSP和 TFSA

我们知道,在加拿大所有的收入,不管是工资、商业、投资等,都要纳税,但只有TFSA里的收益是不需要纳税的,所以叫免税帐户 (Tax-Free Account)。不过由于其名称误导,有些人真把它只作为一个普通的存款帐户,而不去认真打理,从而失去了 Tax Free的意义,所以现在好多业界人士倡议把它改为 Tax-Free Investment Account。其意思就是告诉大家,这是个投资账户!要把它充分运作起来,这是目前唯一一个挣了钱但不需要交税的帐户。政府设置这个账户的本意就是利用税务优待计划鼓励民众多存点钱(因为这边的人过去更喜欢花未来的钱),减轻未来政府的养老负担,也算是间接地稳定社会。这也有可能造成另一个怪圈,不投资没有意义,投资则有风险。记得2008年的时候,许多的RRSP账户损失多达50%,由此引发了对RRSP的许多误解。TFSA同样也面临这样的问题,一旦投资损失,估计也会有人怪罪政府故意设置此类计划“骗人”投资等等。谈论这些的主要目的是让大家既要充分利用TFSA,又要注意投资风险。风险是因人而异也因时而异的,要及时与专业人士沟通并及时调正投资策略。相比与RRSP以及非注册账户,TFSA的损失是最大的。因为RRSP里的资金已经得到了退税的利益;非注册账户里的投资损失(股票、基金等)可以保留,抵消以后(甚至以前3年)的收益;TFSA则无任何此类优待。
关于RRSP,经常被问到这样的问题:“收入为多少时买最合适?”这也是个没有唯一答案的问题。从具体数字上看,是收入越高,购买RRSP获得退税越多,但收入低的人购买RRSP获得退税数额相对于工资的比例却更高。比如,一个年薪$100,000的人购买$10,000的RRSP可获得$3,600的退税,相当于年薪的3.6%;一个年薪$50,000的人购买$10,000的RRSP可获得$2,500的退税相当于年薪的5%。(当然这样得数字比较也没什么多大意义)。RRSP的利益核心又两个:
一是减低购买年(包括第二年的前2个月)的收入,算作取出年的收入。(注意:随时可取,不需要等到退休。)
二是里面的资金收益是Tax  Deferred。
高收入人士无疑是应该购买RRSP的,低收入的人士相对迟疑一些。基本原则是,如果不是手头特别的紧张,或者近期不会有很大的收入提高,还是应该及早购买的。这是一个简单的Present value和 Future value问题。
与RRSP相关的话题还有:
 第一次购房计划(HBP---First Home Buyer Plan)以及返校学习计划(LLP---Lifelong Learning Plan);
 Spousal RRSP 以及RRSP loan等。
欢迎大家参考本论坛的其他文章以及税务局的官方网站查询 www.cra-arc.gc.ca

那么如果资金不太充裕,如何合理分配这两个计划呢?
基本原则是先投入RRSP,因为其税上的利益太大啦。
还有一点要再次提醒,虽然RRSP可以随时取出,但取出后就失去了这些额度,这点与TFSA不一样。

TFSA和RRSP季节已经开始,欢迎大家电话或者email 咨询,也请及时关注即将举办的相关讲座。
Phone:403-993-9668;  Email: andrew.yu@investorsgroup.com
地址:100, 37 Richard Way, SW, Calgary

nyquist stablity

The Nyquist stability criterion
The closed loop system is stable if and only if the net number of anticlockwise encirclements of the point -1+j0 by the Nyquist plot of the system loop gain transfer function G(s) is equal to
the number of poles of G(s) in the right half-plane:
Ncounterclock = P.

open cv

OpenCV Installation Guide
This guide describes how to install and link the OpenCV library 2.1 together with Visual Studio 2008 in order to compile the lab projects developed for this course. Once this process has been completed, full control over the OpenCV library files will be available.
Notes:
  • OpenCV is an evolving project, therefore new iterations of the software will be released in the future. However as the software changes many of the installation steps demonstrated in this document will be the same or will get simpler
  • Building the OpenCV libraries with the Intel IPP will not be covered in this guide, however information on this topic can be found at http://software.intel.com/en-us/articles/intel-ipp-support-model-changed-in-opencv-2x/
  • The compiler that is used in this installation guide is Visual C++ 2008 Express Edition.

1) Installing VS2008 Express
  1. Download Visual C++ 2008 Express Edition from http://www.microsoft.com/express/Downloads/#2008-Visual-CPP
  2. Install Visual C++ 2008 Express Edition


2) Installing OpenCV 2.1
    1. Download OpenCV 2.1 as shown in the image below from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
    2. When installing OpenCV 2.1, make sure that the files are added to the system path for all users
    3. After Installation is complete restart computer.




3) Linking OpenCV 2.1 with Visual C++
  1. Open Visual C++
  2. Open Tools --> Options. Under Projects and Solutions --> VC++ Directories
  3. Select Show directories for: Library files and create a new line with the location of the OpenCV lib folder that was specified during installation
  1. Select Show directories for: Include files and create a new line with the location of the OpenCV include\opencv folder that was specified during installation

4) Test Project
To make sure that everything is functional, a test project will be created to use OpenCV to display an image included in OpenCV sample programs.
  1. Open Visual C++
  2. Go File->New->Project
  3. When the New Project dialog appears select Win32 Console Application and enter a project name
  4. Make sure that your project is empty
  5. Add a .cpp file to you project called main.cpp
  6. Press Alt+F7 or select from the tool menu Project->"your projects name" Properties
  7. Open Configuration Properties->Linker->Input
  8. Beside Additional Dependencies add cv210.lib highgui210.lib cxcore210.lib




  1. Copy the following code into main.cpp
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>

using namespace cv;

int main()
{
char img_file[] = "C:\\OpenCV2.1\\samples\\c\\lena.jpg";


IplImage* img = cvLoadImage(img_file);
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);

cvWaitKey(0);

}
  1. Compile and execute. Congratulations you have just written your first OpenCV program!