Pixytech

Lead Architect  •  Full Stack Engineer

Author: Pixytech

  • Face Detector

    Face detection from given picture has many applications including camera’s, scanners and other consumer application. The technique can be applied to improve the effectiveness of application like driving licence, passport generation, data entry applications etc. Recently one of my friends who is running his data entry business asked for solution for data entry of typical forms which consists candidate picture and relevant data. In tradition application usually one has to spent considerable amount of time in scanning, trimming picture. There is no such scanner or device available to do their job automatically and reduce the time spent in processing or increase the productivity. In this article i have written small .net based application which can be used in wide range of application and is based on open cv haar face detection to recognize front face from input picture.

    The application is just proof-off concept off-course fully working to detect face from camera. The application also implements motion detection from input picture and it will capture the picture only when motion is stabilized. Imaging if this could be integrated with-in scanner having auto feed tray. The application could be programmed to take pictures based of business specific parameters for e.g. for passports there is different specification as compared to driving licence photo’s. The concept could be integrated with Photo-Me (automatic photo machines) machines where current users has to position him self or move the camera using controller keys.
    The application will first wait for any motion if motion is detected and is stabilised for few seconds, it will capture the frame from camera and will be processed by application to detect face from picture and cut the face according to pre-set specification, Say if it detects two faces it will generate two pictures into strip. The concept can be further extended to automatically create data entry into some database with initial picture. The rest of the data will be manually entered by DTP operators. This process will improve the DTP eefficiency at least by 20 % and if it will be incorporated with scanner it may further improve the efficiency by 40 %.

    I have recently upgraded my OS to Windows 7 64 bit and the source code of this application is not working on this os.will publish the code once i have mannaged to fix the issue.

  • .Net Script Editor (C#,Vb.net Mini IDE)

    Complete Visual Studio IDE (source code included) in single user contol that can be used in your windows application to provide scripting feature in languages like c# abd vb.net.IDE have features like code intellisence,reference to .Net assemblies,COM libraries & web services.The code editor supports lot coloring for languages like c,c++ c#,vb.net,sql etc..Refrectoring features like converting c# code to vb.net code in single click.

    Add scripting functionality to your application,features of MS Script control (Functions like AddObject) and some features of VSA/Visual Studio editor like intellisence, code completion etc. Mini .Net IDE in single winform control.

    The source code / article published here is to provide features of MS Script control (Functions like AddObject) and some features of VSA/Visual Studio editor like intellisence, code completion etc. The control supports C# and VB.net language however can be easily modified to support any .net language. You can use COM references, .Net references & Web References. The control supports Visual studio IDE features like bookmark, highlighting interpreter errors & compiler errors, adding multiple classes and interfaces. You can imagine visual studio IDE build in single control with feature like AddObject from MS Script Control. To use this control you just need to drag and drop it to your winforms and add few lines of code to add instance of object which you want to access in the scripts.

    Source code at :
  • Silverlight WebSockets – Duplex Communication

    A duplex communication system is a system composed of two connected parties or devices that can communicate with one another in both directions. Duplex communication is required when you need to send some data in the reverse direction i.e. from Server to client. For scenario purpose assume that something happens on server (some event is received from source) and message from server should be sent to connected clients. Off-course the solution should be highly scalable with low latency client and server.

    Let’s talk about silverlight client in our scenario

     There could be couple of options with silverlight client demonstrated by Gill Cleeren In series of article “The duplex story: looking at duplex communication in Silverlight 4

    Silverlight 4.0 now supports 3 different types of duplex communications

    • HTTP Polling Duplex: Duplex requires that the server can itself initiate communication, which is not supported by HTTP, HTTP Polling duplex (HTTP long polling, or Comet-style) protocol allows us to do bi-directional communication over HTTP. What happens behind the scenes is the following:
      • The Silverlight client initiates the communication by sending an initial request to the service.
      • After the client is registered with the service, it continuously starts polling the service for updates.
      • Whenever the service has new messages to send to the client, they are queued up until a new poll arrives from the client.

    The HTTP Polling Duplex is therefore not real duplexing: it creates an illusion of duplex communication by polling (at network layer) so frequently that it looks as if the messages are pushed from the service to the client. If you still want to use this method here is the link for you to tune performance of http polling duplex.

    • Sockets: Socket is implemented through the use of a TcpListener, Being pure TCP endpoints, sockets are fast and true duplex communicators. However sockets in Silverlight can only work over ports between 4502 and 4534 making it unsuitable for duplex communication over the internet. Secondly you need to build policy server to provide clientaccesspolicy.xml for sockets.Note that Silverlight 4 also allows that the policy calls are made over HTTP.
    • net.tcp binding: this entirely new binding, added in Silverlight 4, also supports duplex communication. net.tcp combines advantages of both polling duplex and sockets. Its programming model is, just like polling duplex, based on WCF. That means that we can take advantage of automatic proxy generation inside Visual Studio.
    • Poll based communication: Not scalable, out of scope.

    So what’s next?

     HTML 5 – WebSockets

    Web socket protocol or WebSockets are “TCP for the Web,” a next-generation bidirectional communication technology for web applications being standardized in part of Web Applications 1.0.

    The Web Sockets API enables web applications to handle bidirectional communications with server-side process in a straightforward way. Once you get a Web Socket connection, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler. The protocol is not raw TCP because it needs to provide the browser’s “same-origin” security model. It’s also not HTTP because web socket traffic differers from HTTP’s request-response model. you do need a new server implementation to communicate with web sockets .

    web socket prototype is out now at http://html5labs.interoperabilitybridges.com/prototypes/available-for-download/websockets/html5protos_Download or websocket msi from here

     for more information see : http://tomasz.janczuk.org/2010/12/websockets-wcf-service-silverlight-and.html

    Please also find the published websocket transport binding (Incomplete project)  here which i was trying to build using custom duplex WCF channel.

  • SNMP Trap Listener

    Simple Network Management Protocol (SNMP) is an “Internet-standard protocol for managing devices on IP networks. Devices that typically support SNMP include routers, switches, Servers, workstations, printers, modem tracks etc. It is used mostly in network management systems to monitor network-attached devices for conditions that warrant administrative attention.

    SNMP exposes management data in the form of variables on the managed systems, which describe the system configuration. These variables can then be queried (and sometimes set) by managing applications.

    The code attached in this article is .net based windows service to trap SNMP messages (SNMP v2) and process them accordingly. The service is capable to handle thousands of messages per second by using .net threads. One thread listens for incoming messages and pump them in message queue while another thread will extract and process the messages from another end of the queue.

    The SNMP service in this article depends on windows “SNMP Trap Service”.

    The source code also includes project “(SNMPSendTrap)” to send test SNMP v2 traps. 

    Download source code for SNMP Listener (Vs2010)

  • Custom Domain Service Factory

    Parameterized constructors are not allowed in WCF RIA domain service, however your object model may requires to have constructor with arguments. For example EmployeeService (in this example) is WCF RIA Domain Service which requires Authentication and have constructor with authenticated User instance as parameter. The activate the service in such scenario you need to provide your own custom domain factory calls and plug the factory in Application_Start event of Global.aspx.

    Sample Employee Service class

    [EnableClientAccess()]
    [RequiresAuthentication()]
    public class EmployeeService : DomainService
    {
            
        public EmployeeService(User user)
        {
                
        }
        //......
            
    }

    Custom Domain service factory

    internal sealed class DomainServiceFactory : IDomainServiceFactory
    {
        private IDomainServiceFactory _defaultFactory;
    
    
        public DomainServiceFactory(IDomainServiceFactory defaultFactory)
        {
            _defaultFactory = defaultFactory;
        }
    
        public static void Setup()
        {
            if (!(DomainService.Factory is DomainServiceFactory))
            {
                DomainService.Factory = new DomainServiceFactory(DomainService.Factory);
            }
        }
    
        public DomainService CreateDomainService(Type domainServiceType, DomainServiceContext context)
        {
            if (domainServiceType == typeof(EmployeeService))
            {
                DomainServiceContext authServiceContext =
                    new DomainServiceContext(context, DomainOperationType.Query);
                AuthenticationService authService =
                    (AuthenticationService)_defaultFactory.CreateDomainService(typeof(AuthenticationService), authServiceContext);
                User user = authService.GetUser();
    
                DomainService domainService = (DomainService)Activator.CreateInstance(domainServiceType, user);
                domainService.Initialize(context);
                return domainService;
            }
            else
            {
                return _defaultFactory.CreateDomainService(domainServiceType, context);
            }
        }
    
        public void ReleaseDomainService(DomainService domainService)
        {
            if (domainService is EmployeeService)
            {
                domainService.Dispose();
            }
            else
            {
                _defaultFactory.ReleaseDomainService(domainService);
            }
        }
    }
    

    Setup Domain service factory

    protected void Application_Start(object sender, EventArgs e)
    {
        DomainServiceFactory.Setup();
    
    }