. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Sunday, May 29, 2005

IHttpModule Things I have noticed

Something I have learnt today whilst playing with is that when the Init method is called you shouldn't access the Context method the HttpAplication exposes because it seems like it is not fully constructed (things like the HttpMethod, QueryString and Form properties are not created).

However, if you handle an event like such:

context.BeginRequest += new EventHandler(Context_BeginRequest);

then once you enter the EventHandler, the Context Object (attached to the source parameter) seems to be fully constructed.

private void Context_BeginRequest(object sender, EventArgs e)
{
_context = ((HttpApplication)sender).Context;



Technorati Tags
[feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , ,

My Related Documents
, ,

Related Amazon Books
Build Your Own ASP.NET Website Using C# & VB.NET: /, ASP.NET Unleashed (Unleashed S.): /, Pro ASP.NET 2.0 in C#: /, Professional ASP.NET 2: /, Introducing ASP.NET 2.0: /, Beginning ASP.Net 1.1 E-Commerce: From Novice to Professional: /, Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: /

IHttpModule Things I have noticed

Something I have learnt today whilst playing with is that when the Init method is called you shouldn't access the Context method the HttpAplication exposes because it seems like it is not fully constructed (things like the HttpMethod, QueryString and Form properties are not created).

However, if you handle an event like such:

context.BeginRequest += new EventHandler(Context_BeginRequest);

then once you enter the EventHandler, the Context Object (attached to the source parameter) seems to be fully constructed.

private void Context_BeginRequest(object sender, EventArgs e)
{
_context = ((HttpApplication)sender).Context;


Technorati Tags
[feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , ,

My Related Documents
, ,

Related Amazon Books
Build Your Own ASP.NET Website Using C# & VB.NET: /, ASP.NET Unleashed (Unleashed S.): /, Pro ASP.NET 2.0 in C#: /, Professional ASP.NET 2: /, Introducing ASP.NET 2.0: /, Beginning ASP.Net 1.1 E-Commerce: From Novice to Professional: /, Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: /

Sunday, May 22, 2005

ASP.Net Query Parameter Validation

I have just been thinking about a subject that has always concerned me with ASP.Net. By Default ASP.Net won't allow certain characters through on the querystring that could potentially cause security problems (such as Cross Site Scripting attacks). The Developer has the opportunity to turn this feature off, but would be required to validate all the elements themselves.

I have just been thinking, wouldn't it be good if when a Page Class is defined you could provide some predicates that must be true for the page not to invalid. For instance a developer could provide a list of all the accepted query parameters and their datatypes and the runtime will take car of validating it automatically. I know you can have custom validators and the like but they must always be called via validate.

Wouldn't it be nice if you could do something like:

[QueryParameterValidation(Text)]
protected TextBox inputName;
[QueryParameterValidation(Numeric)]
protected TextBox inputAge;

[QuertParameterValidFields(inputName, inputAge)]
public class TestPage: Page
{
.....


I am not too sure if this type of thing has been done before, or even if it has any advantages over CustomValidaters etc.

I just thought it might be quite handy, because you could seperate the types out so that a Text attribute wouldn't allow HTML/XML characters and it would remove this before the page is completely loaded. So that once the developer sees the data it is HTML safe.

I will have more of a think about this :).

Thursday, May 19, 2005

FishEye Example Code That Integrates into Tiger Imaging

Here we go I have updated my code, i.e added some comments to it... It produces a fish eye effect described by Jason Waltman based on the paper:

"Devernay, F., and O. Faugeras. Straight Lines Have to Be Straight. 2001. 13 March 2001. http://devernay.free.fr/publis/distcalib-mva.pdf.

Abstract.

Most algorithms in 3D computer vision rely on the pinhole camera model because of its simplicity, whereas video optics, especially low-cost wide-angle or fish-eye lenses, generate a lot of non-linear distortion which can be critical. To find the distortion parameters of a camera, we use the following fundamental property: a camera follows the pinhole model if and only if the projection of every line in space onto the camera is a line. Consequently, if we find the transformation on the video image so that every line in space is viewed in the transformed image as a line, then we know how to remove the distortion from the image. The algorithm consists of first doing edge extraction on a possibly distorted video sequence, then doing polygonal approximation with a large tolerance on these edges to extract possible lines from the sequence, and then finding the parameters of our distortion model that best transform these edges to segments. Results are presented on real video images, compared with distortion calibration obtained by a full camera calibration method which uses a calibration grid.

To be fair I have only glanced at the paper because I already had the algorithm to do the fish eye effect I wanted, but it seems to go more in depth. Specifically it seems to discuss methods to determine if an image has been distored, and how to correct that image into a normal pin hole camera model (i.e a normal looking image like those used to view an eclipse).

I have not noticed any additional copyright information on reproducing the abstract above, nor for examining Jason Waltmans works.

Anyway click Here for the cs


Wednesday, May 18, 2005

Moved the Blog To Kinlan.co.uk

Moved the Blog To Kinlan.co.uk
I have moved the blog onto Kinlan.co.uk, still using the blogger stuff. But I thought it would be nice to have it in my own domain so I can track it better.... I am really impressed with Blogger :)

Looks like I can't update the old account anymore, so looks like I am staying here

yay!

Tuesday, May 17, 2005

I did it.... Fish Eye... Call Me Kinlan The Chuffed!!!

It wasn't too hard.... I did take a peak at the code behind the that Jason Waltman describes. I did this purely because the code I implemented seemed to match the pseduo code that was written but my results were not quite correct. I looked at the code, converted it to c# implemented it as a filter in the Tiger Image Processing Library (Tiger Imaging) for C# here and it worked pretty much the first time it was tan.

I understand a bit more about polar co-ordinates now as well :)

Basically we have are our normal Cartesian Co-ordinates (x,y) which are used on our screens as pixel locations ((0,0) is the top left, (10,10) is 10 pixels in from the top left etc). Polar co-ordinates are co-ordinates that are specified in Angles and units from the center of a Circle .... I think!

So a Polar Co-ordinate (angle = 45, radius = 20) would mean that the point we want is 45 degrees from North and 20 units out from the centre.

This is useful in the Fish Eye Effect which needs to work out what pixels will be in the fish eye region.

The Fish eye effect has two basic stages
  • Work out which pixel should be fish eyed
  • If a pixel needs to be fish eyed, work out where the pixel should be placed based on where it is in the fish eye's view.
Hmm.... Don't know if I made too much sense there, but I will comment the code a bit more and then post it as a link.

Sunday, May 15, 2005

Image Processing: Part 2

There is a really cool (At least I think it is) Image Processing Library (Tiger Imaging) for C# (Code Project). It comes with complete source code and provides some really cool filters that enable you to perform a bit of image manipluation easily. It is by a guy called Andrew Kirillov and he has another article on the code project here where he demonstrates Montion Capture using his library.

I am just wondering if I should create some filters (such as fish eye that Jason Waltman describes). I have some plans for doing a bit of research with Tiger Imaging....

Image Processing: Part 1

I get so many things running through my head that I want to do. I was looking at the Yahoo search API and I found that you can search for
images. So I decided to do some tests to see what I can do with the results and how easy it would be in C# to load the images (it is
really easy, I was well chuffed when it all clicked into place)



string query = http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?;
query += "appid=[SOMEIDSHOULDGOHERE]&";
query += "query=" + txtQuery.Text +"&";
query += "results=5&";
query += "start=1&";
query += "format=any";
imageList = newImageList();
WebRequestwr =WebRequest.Create(query);
using(WebResponse wResp = wr.GetResponse())
{

ImageSearchResponse.ResultSet imgResp = newImageSearchResponse.ResultSet();
using(Stream responseStream = wResp.GetResponseStream())
{
XmlSerializer serializer = newXmlSerializer(typeof(ImageSearchResponse.ResultSet));
imgResp = (ImageSearchResponse.ResultSet)serializer.Deserialize(responseStream);
}
//Add the images into
int imageIdx = 0;
foreach(ImageSearchResponse.ResultTypert in imgResp.Result)
{
WebRequestwrImage =WebRequest.Create(rt.Url);
using(WebResponse wRespImage = wrImage.GetResponse())
{
Stream sr = wRespImage.GetResponseStream();
System.Drawing.ImageinsertImage = Bitmap.FromStream(sr);
imageList.Images.Add(insertImage);
}
}
lstImages.Items.Add(rt.Title, imageIdx++);
}
lstImages.LargeImageList = imageList;


Basically the above code construct a REST Query to send to Yahoo, inside the REST Query are the parameters for the search and its results.
The WebRequest is created and the WebResonse is recieved. The Xml feed is then serialized into a custom datatype that is created from
Yahoo's schema via the xsd.exe tool.


The custom data type is then iterated across, because each item in the ImageSearchResponse.Result is an image that matches our searcg
criteria.

A new query is then created to download this image from the site that Yahoo is pointing to. The response stream is returned and an image
created directly off this via Bitmap.FromStream(); The Bitmap is then loaded into an ImageList.

Running GACUtil in Build for Visual Studio 2005

It took me absolutly ages to find why I couldn't run GACUtil or the RegAsm.exe from a build script. It is because VS2005 Beta 2 doesn't seem to load the PATH Envionment variables at build time. This results in VS2005 Beta 2 not being able to find the files it needs. There is a simple cure to this problem

The Following doesn't work and causes build errors (because the build script doesn't run)
cd $(ProjectDir)\bin\Release

gacutil.exe /if Favorites.dll
regasm Favorites.dll
If you add the following line in: CALL "%VS80COMNTOOLS%\vsvars32.bat" > NULL
so that you get:
CALL "%VS80COMNTOOLS%\vsvars32.bat" > NULL
cd $(ProjectDir)\bin\Release

gacutil.exe /if Favorites.dll
regasm Favorites.dll
It works fine. The extra line in the build script seems to load the environment varibles that VS2005 Beta 2 needs.



Technorati Tags
[feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , ,

My Related Documents
, , ,

Related Amazon Books
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: /, Teach Yourself Visual Basic.NET in 21 Days (Sams Teach Yourself S.): /, Windows Forms Programming in C#: /, ASP.NET Unleashed (Unleashed S.): /, MCAD Training Guide 70-316: Developing and Implementing Windows-based Applications with C# and Visual Studio.NET: /