Just thought I’d post this one for the folks at home to prove that we are getting outdoors occationally 😉
Nasty little ASP.NET 401 problem
I discovered this nasty little problem the other day while building a couple of simple little pages and I thought I should post it so I don’t forget and waste ages on it again!
Essentially the issue is that if you have custom error pages for different types of http status codes such as 401, 403 or 404 then you will have be prepared to do a little bit coding for your 401 page to be displayed unlike your other error pages which you can automatically redirect to by turning on customErrors in the web.config file like so:
<customErrors mode=”Off” defaultRedirect=”Error.htm” >
<error statusCode=”403″ redirect=”AccessDenied.htm”/>
</customErrors>
The problem with 401 is that if you are using the web.config authorisation section as well, and you have explicitly denied the user permission then their request will be authenticated but not authorised and appears to be terminated before the ASP.NET custom error handler can run. For example:
<location path=”MySecurePage.aspx”>
<system.web>
<authorization>
<allow users=”james” />
<deny users=”*” />
</authorization>
</system.web>
</location>
Here the only way to redirect your user to your custom error page will be to check for this condition in the application_end event in the global.asax like so:
protected void Application_EndRequest(Object sender, EventArgs e)
{
if (Response.StatusCode == 401 && Request.IsAuthenticated == true)
{
Response.ClearContent();
Response.Redirect(“AccessDenied.htm”);
}
}
Note: trying to set your custom 401 page in IIS won’t work either as user is authenticated by IIS, but their authorisation fails at the ASP.NET level
Nasty!
Thanks to Ashraf Moollan
Some productive hacking
Over the weekend I have made a pretty decent amount of progress with my vision project. I have created a simulated stereo system by taking images with the camera on the left hand side, moving the camera and then taking images of the same scene from the right hand side. I then load these images from disk simultaneously to simulate the effect of having two cameras. Hopefully I will get my other camera soon as this solution won’t work for long.
I am now at the point where I can match features between the stereo images and extract depth information from the stereo nature of the images. I have also completed the matrix mathematics that will give an estimate of the image coordinates of a given feature in the next frame given the camera translation between frames. This last bit of work was a bit challenging as it required me to relearn a bunch of linear algebra and trigonometry which I hadn’t used since University.
My next challenge is to use least squares minimisation on the features successfully matched between frames to find the error between the projected feature location and the actual feature location. This will then feed back into the camera location calculations as a sort of error term. I am thinking I may even use a kalman filter to integrate the robot odometry and calculated camera ego motion.
I still have a long way to go before this prototype is finished and I know whether the system will even work or not, but it is pretty exciting to be able to do what I have already accomplished!
Mono and Monodevelop – state of the nation
I installed the new builds of mono and monodevelop last week and having used them a little over the last couple of days I can say they are pretty neat so far.
I haven’t used any of the new features in mono (since 1.1.4) but it does seem to be a little faster, and also fixed a nagging problem I had where everytime I rebooted my machine I had to delete my ~/.wapi directory before I could build/run any mono application.
Monodevelop is looking a little more polished since the 5.1 release. It also runs on 64bit native mono at last which I am totally stoked about! I also installed a (experimental) plugin for svn integration that had been posted to the monodevelop mailing list and this looks promising, although the history functionality crashes monodevelop on my machine (I suspect this may be to do with the version of svnlib I have installed). My only complaints at the moment are that it is a little unstable and seems to crash unexpectly (I’m planning to figure this out and submit a bug report at some stage), and the lack of C# 2.0 syntax support. I am using generics pretty heavily in my current project and including this syntax totally breaks code completion.
Monodevelop is a pretty promising IDE and a great project which I would love to contribute to, if only I had a little more time!
In slightly unrelated geekage, I finally got round to setting up some samba shares on my home network last weekend. So now my house mates can all stream mp3s, video etc from my machine via the wifi network. It’s pretty cool having Linux, Mac and Windows machines all interoperating nicely togeather!
I wish weekends were three days long…
Well, it’s Sunday night and I really wish that weekends were three days long. I could really do with just one more day off this weekend. I feel like I haven’t had a decent break in ages and need a bit of relaxing and unwinding time. Most of the travelling Anthea and I do is pretty full on and not much time for relaxing so I haven’t really had a break since Christmas and beginning to feel a bit flat.
Had a few little wins over the weekend and am feeling pretty happy about it. I finally seem to have my xdaIIi syncing with Evolution properly. I am using SynCE and multisync to sync my Evo contacts, task list and calendar. It seems like a pretty solid setup now. I think my initial problems were down to some faulty partnerships I created while trying to set everything up.
I also managed to get a bit of solid hacking done on my Vision project this weekend. I don’t really have any visable results to show for my efforts, but I know I am making progress. Hard to explain to your significant other that you are really excited because you’ve finally figured out how to calculate the intrinsic matrix for your camera and undistort images 😉
I also managed to get some of the translation and rotation matrix multiplication working. Well actually it’s still untested as of yet, but it compiles and runs. I am rapidly approaching the point where I am going to need to get the other camera now so I can do proper stereo. I was holding off purchasing until I was sure I was going to be able to get the first one working correctly with opencv and mono and have now reached the point where I am pretty happy with it.
Anthea and I went for a huge walk around Hyde park in the sun today. It’s amazing the change in Londoners when spring rolls round and the sun comes out. I’m sure half of London was in the park playing frisbee or walking the dog or playing with the kids, and it’s really nice to see so many people out and enjoying themselves.
Gmail is cool
Ok, I have to say it, gmail is really great. I wasn’t a big fan of the whole conversation thing when I first started using it but now I love it to bits.
Never enough time
So I haven’t blogged in ages. I have been pretty busy with various things, but unfortunately haven’t been able to make much progress on my Vision system lately.
Anthea and I spent 4 days in Prague over the Easter break which was cool. It is a really beautiful city if you can get past the hordes of tourists. Also not quite as cheap as people make out either. I am planning to put photos up on the website soon (I know, you’ve heard that before!).
Finally got my new phone last week, an xdaIIi. Very cool device and I’m loving it so far. Had a bit of fun last night trying to build synce to get it syncing with linux. Unfortunately synce and all its dependancies are hard masked for amd64 on Gentoo, so I had to build it all in my 32bit chroot and am going to try running all the 32bit binaries with linux32 from my 64bit environment. I got as far as creating a serial connection last night and that worked so I think this strategy might just succeed.
Am going to see Neil and Tim Finn in concert at the Royal Albert hall tonight, so won’t have a chance to push on any further with the vision system. I am struggling with the opencv calibration routines at the moment. I need to use these to extract my cameras intrinsic parameters, focal length etc, but it is proving very difficult so far. Hopefully some dedicated hacking this week/weekend will see some progress.
Some progress
Well I’ve made a little progress tonight. I managed to get the conversion from an opencv image (IplImage) format to an ImageMap (essentially an 2d array of doubles) working. This now means that all my work using libsift so far now works nicely with opencv!
I also managed to get a simple C# test app running where I continuously grab frames from my Logitech Quickcam Pro 4000 and display them to the user. It essentially just calls all the opencv and highgui methods using P/Invoke but it’s working well.
It’s finally looking like I might start making some progress again!
Oslo and the news
I have just come back from a great weekend in Oslo. It’s a interesting place although not really at all like Stockholm which came as a bit of surprise to me. Anthea and I did as much site seeing as we could getting to the Viking ship museum, Folk museum, sculpture park and ski jump in the one and a half days we were there. I’ll post the photos to the travelling section of my website shortly.
Saw this on slashdot today. It appears that MDRobotics (makers of the Canada arm I & II on the International Space Station) have been working on a similar project to me. They have created some software that can reconstruct a 3d model of a scene photographed by a stereo camera system. Their software also uses Lowe’s SIFT features.
A little progress
Well I managed to get the quickcam displaying the full resolution image using opencv. It turns out that it was capturing at 640×480 the whole time, it just wasn’t displaying the whole image. A bit of tweaking to the capture properties and everything started working correctly. Specifically I needed to add these lines:
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
I was also having a little bit of trouble getting at the raw image data from C# as you access it like this using C:
pix = ((uchar*)(img->imageData + img->widthStep*y))[x];
I ended up writing a function that looks like this (where imageData is an IntPtr):
/// This method is used to get the value of a single pixel from the
/// underlying C array.
private unsafe byte GetPixel(int x, int y)
{
// the image data is in one long contiguous array so we need to
// skip y rows of widthstep values before adding our x value to
// index to the right x point in the right row.
return (byte)(((byte*)this.Image.imageData) + this.Image.widthStep * y)[x];
}
Hey… it works 🙂
