Skip to main content

Posts

Showing posts from July, 2019

Highlight active rink area on the normalized rink image

figure 1 Let's do more adventure following yesterday's work. Highlight the rink to show the active play area as following: figure 2                                                                             The red highlight area is exactly the active play area from figure 2. In order to get it, firstly resize the rink image to match with play image. so we can use for pixel to pixel mapping. create black/white mask from resized rink image: figure 3 truncate the play image suing figure 3 and then create active red area figure 4 Finally weightly add figure 4 to the normalized to generate figure 1. Here is source code:

how to map the hockey rink from camera to the normalized rink using opencv

As the dad of hockey player, what can we do if we don't know how to skate?! yes, we can write the code. As the name of loving, do whatever we can do for kids. The final object is to create a video analysis system automatically which will use deep learning to analysis the video, tracing all player's position/movement and collect the athlete data. However,  a thousand miles begins with a single step.  The first step of today is to resolve the fundamental challenge - map the rink from video image to organized rink image. The image transformer is very straightforward as the first version. OpenCV api provided 2 different ways to resolve it: 1.  getPerspectiveTransform : support only 4 points mapping 2. findHomography: support at least 4 points mapping. I wrote a quick code to help mark the key points from original image: and we generated the image with key point marked the python code could be simple as well Make sure each of point is mapped to organized

Inside Spring Framework from Source Code (4)

In the last post, we go through the whole process about how to register a regular <bean>.  Now, let's take a look at how to load <import> tag: < import resource = "services.xml" /> < import resource = "resources/messageSource.xml" /> < import resource = "/resources/themeSource.xml" /> </import> see the entry code here: importBeanDefinitionResource has all the implementation. the logic is as following: 1. get the value of attribute: resource 2. resolve the location string by replacing system properties: e.g. "${user.dir}" 3. check the location is starting with classpath or regular url. 4. Line 26 will use AbstractBeanDefinitionReader-> loadBeanDefinitions to parse the spring beans as mentioned in my previous blog.  g et the file resource list (if the location path contains "*" or "?") or return the file resource directly. parse the resource to spring be

Inside Spring Framework from Source Code (3)

In the previous post, we just go through how code step to step and starting load spring beans. For different node type, the related loading code are different. BEAN_ELEMENT: ParseBeanDefinition Example of xml BeanDefinitionParserDelegate.parseBeanDefinitionElement The second parameter containingBean is used to parse a value, ref or collection sub-element of a property or constructor-arg element. Here we just parse the regular bean, just leave the value as null. Firstly, the attribute “id” and “name” are retrieved from <bean/>. The name is used for alias purpose. The value could be “name1,name2;name3” with dilimiters {,;} If there is Id assigned, the first name will used as bean id and the left be used as aliases. Once the id and name are done, parseBeanDefinitionElement A bean Definition is returned and add the bean name to bean definition holder. We will go over all the logic later to see how will generate the bean name automatically when bean name is empty from x