AVIFile API to capture video frames in Microsoft Windows

Posted: 21st March 2011 by Adnan Noon in OpenCV

To develop computer vision applications which require video processing , the most important step is to read video frame by frame. OpenCV is great C++ API for such applications. OpenCV function cvQueryFrame can grab and return a frame from camera or file but it doesn’t support all video formats. DirectShow API is another option to perform frame capture but it is too complex for simple applications. Microsoft provides another relatively simple simple API for reading videos named AVIFile API.  It contains set of powerful functions to read, create and edit AVI files. It is part of a larger API called VFW  (Video for Windows). The VfW AVI support should use the same DirectShow facility with dynamically configurable filter/codec support in Windows. It means that if you get an avi file with unsupported encoding, installing the corresponding codec to Windows should make the application written with AVIFile API work immediately without any code change. Recently I developed a computer vision application to remove noise from low quality/resolution night videos using AVIFile API. I was unable to read H.264 videos in my application untill I installed H.264 codec using ffdshow.

There is very good C# Wrapper available for AVIFile functions on codeproject.

Information on AVI File Formats is available here.

The only drawback of AVIFile API is that the code is not portable and works only on windows in contrast to OpenCV which works on Linux as well.

I was developing a multimedia application to process and play *.avi files using AVIFile API when i encountered this problem. The application was working fine on one system with Windows XP installed but continuosly crashing on another system with same OS and configurations. While troubleshooting this problem I got to know that It is really simple to display list of installed video and audio codecs on Windows 7 and Windows XP using Windows Media Player 11 or higher.

1. Open Windows Media Player

2. Press ALT key to display the Menu of WMP.

3. Select Help -> About Windows Media Player

A1

4. Click on the link Technical Support Information.

A2

5. A web page will open in your default browser with list of all audio, video codecs and filters installed in your system.

A3

If you are developing an image processing application using OpenCV and you want to display pixel values of images, it might not be possible to display all pixels on console due to large size of images. Following code snippet dumps the pixel values of OpenCV image to a text file in readable format. You can then open the created file in any text editor and analyze the pixel values of image.
Recently i was developing an image processing application and my output file was DLL rather than executable. One of the functions in code was returning black image, to debug my code i wrote this function and dumped intermediate images to files and eventually i was able to fix the bug.

#include<stdio.h>
/*
Function takes OpenCV image as input and dumps its pixels to a file specified by filename in function arguments.
*/
int WritePixelsToFile(IplImage *img,const char *filename)
{
  /*open a file in text mode with write permissions.*/
 FILE *file = fopen(filename, "wt");
 if(file==NULL)
 {
  /*If unable to open the specified file display error and return.*/
  perror("Unable to open specified file");
  return -1;
  }
  int i,j;
  CvScalar s;
  CvSize size=cvGetSize(img);
  for(i=0;i< size.height;i++)
     {
      for(j=0;j< size.width;j++)
        {
         s=cvGet2D(img,i,j); // get the (i,j) pixel value
         fprintf (file,"%f\t",s.val[0]); // dump the (i,j) pixel value in file 
        }                         
      fprintf(file,"\n");//write new line in file to seperate rows.         
     }
     /*release the file pointer.*/
 fclose(file);
 return 1;
} 

Allegations on General Parvez Musharraf

Posted: 7th October 2010 by Adnan Noon in Pakistan Affairs

General Musharraf conducted a coup on 12th Oct 1999 and dismissed then elected government of Nawaz Sharif by abrogating the constitution. Following is the long list of his crimes.

  1. Abrogation of constitution and dismissal of elected government.
  2. Imposition of dictatorial rule in the country.
  3. The Lal Masjid Operation.
  4. Murder of Nawab Akber Bugti.
  5. Promulgation of the defunct National Reconciliation Ordinance (NRO).
  6. Removal of Justice Iftikhar Chaudhry as the chief justice of Pakistan.
  7. Incident of 12th May 2007.
  8. Starting war against its own people in interest of United States.
  9. Illegal transfer of Pakistani citizens including Dr. Afia Siddiqui to United States for dollars.
  10. Allowing drone attacks in territory of Pakistan by United States.
  11. Abduction of innocent Pakistanis.
  12. Pakistan Steel Mills privatization case.
  13. Punjab Bank Fraud case.
  14. Putting seeds of suicide bombings in country.
  15. Destruction of the moral and Islamic values of nation in the name of enlighten moderation.
  16. Making the “Beard” and “Burqa/Hijaab” as symbol of terrorism.
  17. Eliminating Kashmir freedom movement.

Economic growth of Pakistan in Musharraf’s regime

Posted: 7th October 2010 by Adnan Noon in Pakistan Affairs

Economic Comparison 1999-2007.

Category 1999 2007
Economy $ 75 billion $ 160 billion
GDP Purchasing Power Parity (PPP) $ 270 billion $ 475.5 billion
GDP per Capita $ 2,000 $ 3,004
Pak revenue collection Rs. 305 billion Rs. 708 billion
Pak Foreign reserves $ 700 million $ 17 billion
Pak Exports $ 7.5 billion $ 18.5 billion
Textile Exports $ 5.5 billion $ 11.2 billion
KHI stock exchange $ 5 billion at 700 points $ 70 billion at 14,000 points
Foreign Direct Investment $ 1 billion $ 8 billion
Debt servicing 65% of GDP 26% of GDP
Poverty level 34% 24%
Literacy rate 45% 53%
Pak Development programs Rs. 80 billion Rs. 520 billion
  • Public sector institutions numbers increased from 110,267 (in 1999) to become 164,579 (2006)
  • Private sector institutions numbers increased from 36,096 (in 1999) to become 81,103 (in 2006).
  • There were 2652 PhDs in Pakistan in 1999 which increased to 6405 by 2009. 3753 PhDs were produced in 10 years.
  • IT industry value increased to around $2 billion, including $1 billion exports and employed around 90,000 professionals.
  • CNG sector attracted over $70 billion investment; and created 45,000 jobs.
  • Telecom sector attracted around $10 billion in investment and created above 1.3 million jobs.
  • Industrial Parks were being setup throughout the country for the first time in Pakistani history! M3 estate, Sunder industrial estate, Chakri, etc.
  • Major Mega projects like the Saindak, Rekodiq, Marble production, Coal production and Mining & Quarrying were being pursued.
  • 4 dams: Mirani, Subakzai, Gomalzam, Khurram Tangi dams.
  • Motorways completed or under construction: M1, M3, M8, M9, M10, M11.
  • Six major highways under construction.
  • GWADAR advance mega Sea port developed under his vision!
  • Historic 100% increase in Tax collection of $11 billion.
  • Large scale manufacturing is at 30 years high, and Construction activity is at 7 years high.
  • Newly found World class copper- gold deposits in Chagai will fetch $600 million per year.
  • A new Oil refinery with UAE will fetch $5 billion & will process 300,000 oil barrels a day.
  • Industrial sector registered 26% growth.
  • GDP growth was 3.1% in 1999 which was recorded 8.4% in 2005 and 7% in 2007.

source

Bazgasht by Amjad Baig

Posted: 19th August 2010 by Adnan Noon in Misc, Urdu Books
Title : Bazgasht
Author : Amjad Baig
Baazgasht by Amjad Baig (104)

Mastani Novel by Monis Khan

Posted: 19th August 2010 by Adnan Noon in Misc, Urdu Books
Title : Mastani Novel
Author : Monis Khan
Mastani Novel by Moonis Khan (117)

Khuda Ki Tareekh by Karen Armstrong

Posted: 19th August 2010 by Adnan Noon in Misc, Urdu Books
Title : Khuda Ki Tareekh
Author : Karen Armstrong
Khuda Ki Tareekh by Karen Armstrong (121)

Ishq Ka Qaaf by Sarfraaz Ahmed

Posted: 19th August 2010 by Adnan Noon in Misc, Urdu Books
Title : Ishq Ka Qaaf
Author : Sarfraz Ahmed
Ishq Ka Qaaf by Sarfraaz Ahmed (103)

Ishq Ka Sheen by Allem Ul Haq Haqi

Posted: 19th August 2010 by Adnan Noon in Allem Ul Haq Haqi, Urdu Books
Title : Ishq Ka Sheen
Author : Allem Ul Haq Haqi
Ishq Ka Sheen by Allem Ul Haq Haqi (77)