FILE: CORNERDETECTOR\README.TXT ACTIVEX CORNERDETECTOR V1.0 ----------------------------------------- 1. About CornerDetector ActiveX Server. 2. Known Limitations 3. Files 4. Installation 5. Matlab Use 6. C++ Use 7. Technical Information ------------------------------------------ 1. About CornerDetector ActiveX Server. CornerDetector is an ActiveX server object that performs Harris Corner Detector on digital images. It exposes its internal functionality to most programming languages and environments in Windows platforms. It was designed to be accessed via Matlab and C++ clients, but can be used by other compiled/scripted languages. 2. Known Limitations - Only allows grayscale images. - Only allows 1 byte per pixel images - "unsigned char *" in c++ - "uint8" in matlab - Image number of columns should be a multiple of 4 - Only works with MATLAB 6.0 or later. - Requires OpenCV 2.0 or later 3. Files CornerDetector is distributed in a zip file (CornerDetector.zip) and includes the following files: CornerDetector.bin - the binary code implementing the object functionality CornerDetector.tlb - the type library required for use with compiled languages README.TXT - this file PROBLEMS.TXT - Description of some problems found in this release INSTALL.BAT - The registration script required to install the object UNINSTALL.BAT - The registration script required to uninstall the object TEST.M - Matlab script file with an example of using the object TEST.EXE - compiled program to test the object; requires the Microsoft Vision SDK TEST.CPP - C++ Source code for test program TEST.BMP - Image for tests 4. Installation The CornerDetector encapsulates functions from the Intel Open Source Computer Vision Library http://www.intel.com/research/mrl/research/opencv so make sure you install this library before using the ActiveX object. Please check the documentation of this product for installation instructions. Installation of the CornerDetector - Unpack the "CornerDetector.zip" file to a new directory. - Run the registration script "INSTALL.BAT" - If you have the Microsoft Vision SDK installed, you can run the TEST.EXE application to test the ActiveX object. 5. The CornerDetector object can be called by any ActiveX aware scripting languages like Java, VisualBasic and Matlab. Please check the file TEST.M to see a complete example of using the object in Matlab. The following lines shows the basic use of this object in Matlab: %CREATE THE ACTIVEX OBJECT > h = actxserver('CornerDetector.CoCornerDetector'); %READ ONE IMAGE FROM FILE > img = imread('myimage.bmp') ; %GET IMAGE SIZE > imgsize = size(img); %CONFIGURE OBJECT COMPATIBLE WITH IMAGE SIZE > h.lines = imgsize(1); > h.columns = imgsize(2); %ALLOCATE ACTIVEX INTERNAL RESOURCES > invoke(h,'create_corner_detector'); %MATLAB REPRESENTS DATA COLUMNWISE. USE THE TRANSPOSE > img_t = img'; %DETECT CORNERS > a = invoke(h,'detect_corners',img_t); %VISUALIZE DETECTED CORNERS - THERE IS A 1 PIXEL OFFSET %BETWEEN THE ACTIVEX OBJECT AND MATLAB COORDINATES > imshow(img); hold on; plot(a(:,1)+1, a(:,2)+1, '+'); hold off; %GET THE IMAGE WITH THE EIGENVALUES (SINGLE PRECISION VALUES) > b = h.eig_image; %VISUALISE EIGENIMAGE (TRANSPOSE IMAGE AND CONVERT TO DOUBLE PRECISION) > figure;colormap('gray');image(double(b')); %CLOSE OBJECT > invoke(h,'destroy_corner_detector'); > release(h); For more information check matlab help on integration with activex objects 6. C++ Example. The CornerDetector object can also be used with compiled languages and takes advantage of their flexibility to create highly optimized code. It exposes functions that allow the internal access to data structures, avoiding expensive data transfers between the object and the client, but reducing the robustness against programming errors. These functions are not available to scripting languages due to reliability requirements. Please check file TEST.CPP to see a complete example of using the component in C++. If you have the Microsoft Vision SDK installed in your system, you can compile and run the test application. The following lines present some code to create and access CornerDetector objects. //REQUIRED FOR COM EXTENDED FUNCTIONS #define _WIN32_WINNT 0x0400 //LOAD TYPE INFORMATION DATA #import "..\CornerDetector.tlb" no_namespace named_guids void func(void) { long image_lines = 100; long image_columns = 200; unsigned char *image = (unsigned char*)malloc(image_lines*image_columns); float *eig_image; long max_corners = 100; float *coords = (float*)malloc(2*max_corners*sizeof(float)); /* fill image with data - user should provide this*/ // my_get_image(image, image_lines, image_columns); //INITIALIZE COM HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); //CREATE ATIVEX OBJECT ICornerDetector *ptr; hr = CoCreateInstance( CLSID_CoCornerDetector, NULL, CLSCTX_INPROC_SERVER, IID_ICornerDetector, (void**)&ptr); //CONFIGURE OBJECT COMPATIBLE WITH IMAGE AND CORNER ARRAY SIZES hr = ptr->put_lines(image_lines); hr = ptr->put_columns(image_columns); hr = ptr->put_max_corners(max_corners); //ALLOCATE THE CORNER DETECTOR hr = ptr->create_corner_detector(); //ASK FOR THE DIRECT ACCESS INTERFACE _ICornerDetector *ptr_direct; hr = ptr->QueryInterface(IID__ICornerDetector, (void**)&ptr_direct); //DETECT THE CORNERS long corners_detected = max_corners; hr = ptr_direct->_detect_corners(image, coords, &corners_detected ); //GET THE EIGENIMAGE hr = ptr_direct->_get_eig_image(&eig_image); //direct access to internal pointer //do not write on this memory //CLOSE EVERYTHING ptr->destroy_corner_detector(); ptr_direct->Release(); ptr->Release(); CoUninitialize(); } 7. Technical Information Exposed Functionality interface ICornerDetector : IDispatch { [propget, id(1)] HRESULT quality([out, retval] float *pVal); [propput, id(1)] HRESULT quality([in] float newVal); [propget, id(2)] HRESULT min_distance([out, retval] float *pVal); [propput, id(2)] HRESULT min_distance([in] float newVal); [propget, id(3)] HRESULT max_corners([out, retval] long *pVal); [propput, id(3)] HRESULT max_corners([in] long newVal); [id(4)] HRESULT detect_corners([in] VARIANT image, [out,retval] VARIANT * corners); [propget, id(5)] HRESULT lines([out, retval] long *pVal); [propput, id(5)] HRESULT lines([in] long newVal); [propget, id(6)] HRESULT columns([out, retval] long *pVal); [propput, id(6)] HRESULT columns([in] long newVal); [id(7)] HRESULT create_corner_detector(); [id(8)] HRESULT destroy_corner_detector(); [propget, id(9)] HRESULT eig_image([out, retval] VARIANT *pVal); }; Properties quality Type: float Arguments: none Initial Value: 0.06 Description: threshold on minimum eigenvalue to accept corners min_distance Type: float Arguments: none Initial Value: 5.0 Description: minimum distance between corners (pixels) max_corners Type: long Arguments: none Initial Value: 400 Description: Maximum number of possible corners lines Type: long Arguments: none Initial Value: 144 Description: Number of image lines columns Type: long Arguments: none Initial Value: 192 Description: Number of image columns eig_image Type: VARIANT SAFEARRAY(columns,lines) : VT_R4 Arguments: none Initial Value: none Description: Image of eigenvalues Methods create_corner_detector: allocates object internal data Input Args: none Output Args: none destroy_corner_detector: frees object internal data Input Args: none Output Args: none detect_corners: Runs corner detector Input Arguments: image Type: VARIANT SAFEARRAY(columns,lines) : VT_U1 Output Arguments: corners Type: VARIANT SAFEARRAY(2,) : VT_R8 interface _ICornerDetector : IUnknown { [local] HRESULT _detect_corners([in] byte *image, [out] float *coords, [out] long * corner_count); [local] HRESULT _get_eig_image([out] float ** ppimage); }; Methods _detect_corners : Runs corner detector Arguments: image: input image Type: byte[lines*columns] coords: output (x,y) corner coordinates Type: float[2*max_corners] corner_count: adress of variable to contain number of detected features Type: &long _get_eig_image : gets pointer to object internal image of eigenvalues Arguments: ppimage: address of variable to contain pointer to image Type: &float* AUTOMATION NAME CornerDetector.CoCornerDetector COM INTERFACES: IUnknown IDispatch ISupportsErrorInfo DEFINED INTERFACES: ICornerDetector (dual) (default) _ICornerDetector (local) COM PROPERTIES Aggregatable Free Threaded Marshaler Threading Model : Both For more information check the OLE/COM object viewer - Object CoCornerDetector Copyright (c) 2001, Alexandre Bernardino - ISR/IST. All rights reserved. alex@isr.ist.utl.pt