VideoHelp Forum
+ Reply to Thread
Results 1 to 17 of 17
Thread
  1. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Hi
    We're developing a native video surveillance application. Client-side code is C# and server-side code is C++ on Linux.
    The customer is going to buy some new Panoramic cameras (Bosch Flexidome Panoramic 5000). Now we need to add support for such a camera to the solution.
    I tried to programmatically dewarp the camera image, but I couldn't get a so good image.
    Then I found this on YouTube:
    https://www.youtube.com/watch?v=ziz3ZWNnzKE
    I need exactly the same. But I need some document/info which may lead me to producing such a code.
    At first, I prefer the camera to do dewarping, because it takes so much resources on server or client to dewarp, while it may do it by its hardware or firmware in real-time.
    So I need to know how is it possible and how programs like this do it.
    Any info about it is appreciated.
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    AFAIK, It is not ever dewarped in camera.

    However, view can be generated clientside much quicker with kind of cheat by using LUT instead of underlying transform.

    Scott
    Quote Quote  
  3. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    What is LUT?
    Quote Quote  
  4. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Look Up Table.
    Quote Quote  
  5. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    hmm, i couldn't figure out what method you mean.
    when i type the camera url in browser, i see that the web client of the camera has such ability. it's unlike that it's implemented client-side. it seems that the camera may give streams from parts of the fisheye i choose.
    Quote Quote  
  6. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    Videos like this:
    https://www.youtube.com/watch?v=p1kCR1i2nF0
    show programs which have been written to correct the fisheye effect as much as possible and give as correct as possible image. But the output image can't be the same as non-fisheye cameras. They have an unnatural perspective. Besides, the written source is so complex, calibration is required for each camera, etc.
    For this, I need to undistort just a small part of the original image. In my application, I prefer to give users the ability to specify pan, title and zoom to get different images from the same input.
    Please give me a clue.
    Thanks
    Quote Quote  
  7. I think you are looking for something like http://lensfun.sourceforge.net/
    Quote Quote  
  8. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    how can i make sure?
    Quote Quote  
  9. Originally Posted by hamidi2 View Post
    how can i make sure?
    Check it - it is free and IMHO designed to correct lens distortion. Alternatively ffmpeg has very simple lens correction filter.

    http://www.stjhimy.com/posts/2016-10-27-ffmpeg-lens-correction/
    https://stackoverflow.com/questions/30832248/is-there-a-way-to-remove-gopro-fisheye-using-ffmpeg
    Quote Quote  
  10. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    I think it's impossible to get a "correct" image after correction. It will differ from the real (original) image anyway. The perspective differs, some pixels will be repeated (stretched), some are not and the dimensions differ from the original landscape. For this, I'm looking for a "rectilinear" transformation. What is suggested is to "calibrate" and then "correct" the whole image by the calculated matrices during calibration and this is not what I'm looking for it. I'm looking for correcting specific parts of the whole image to get the best, most accurate, and most adaptable image to what the original landscape has been. If you refer to the first link I gave from youtube in this post, you'll find what I'm looking for.
    Thx
    Quote Quote  
  11. Originally Posted by hamidi2 View Post
    I think it's impossible to get a "correct" image after correction. It will differ from the real (original) image anyway. The perspective differs, some pixels will be repeated (stretched), some are not and the dimensions differ from the original landscape. For this, I'm looking for a "rectilinear" transformation. What is suggested is to "calibrate" and then "correct" the whole image by the calculated matrices during calibration and this is not what I'm looking for it. I'm looking for correcting specific parts of the whole image to get the best, most accurate, and most adaptable image to what the original landscape has been. If you refer to the first link I gave from youtube in this post, you'll find what I'm looking for.
    Thx
    Once again, seem you or ma are confused - provided YT link shows lens distortion and corrected image and by definition yes, unless you camera sensor offer sufficient resolution then pixels need to be interpolated. Provided by YT link is exactly what i made, - functionality like splitting views and navigation over large "panorama" is just software functionality related to image after dewarping.
    One thing i don't understand is adaptation part - are you saying that your lens has adaptive shape? It is made from liquid?

    Look at 3d algorithms - texture to surface mapping - lens work as sphere (hemisphere) and rectangular pixels are wrapped over sphere thus "rectangularity" is distorted, to restore rectangular pixels you need to apply inverted distortion surface. This is your dewarping transformation... and yes, if your texture resolution is insufficient then you will loose resolution - that's why camera sensor need to be super high resolution.
    Quote Quote  
  12. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    First of all, let's obtain a common literature. Since my mother tongue is not English, I may use improper words like adaptable. Let me describe what I got as well as what I need.
    First, let's assume that the lens has enough resolution. For making a panoramic image, I thought to map pixels in the original round image (hemisphere) to a rectangle. For this, I thought to cut the circle from its center to its bottom-side point (the vertical radius) and then calculated with the following formula which I know think has not been correct:
    private void button1_Click(object sender, EventArgs e)
    {
    var bmp = new Bitmap(pbDest.Width, pbDest.Height);
    for (var row = 0; row < pbDest.Height; row++)
    for (var col = 0; col < pbDest.Width; col++)
    {
    var R = bmpSrc.Height / 2.0;
    var r = R * (pbDest.Height - row) / pbDest.Height;
    var theta = 2 * Math.PI * col / pbDest.Width;
    var alpha = theta - Math.PI / 2;
    var xSrc = (int)(bmpSrc.Width / 2.0 + r * Math.Sin(alpha));
    var ySrc = (int)(bmpSrc.Width / 2.0 - r * Math.Cos(alpha));
    try
    {
    bmp.SetPixel(col, row, bmpSrc.GetPixel(xSrc, ySrc));
    pbDest.Image = bmp;
    }
    catch
    {
    }
    }
    }
    I know that here's not a programming forum. I just wanted you know my calculations and my approach. The result is this:
    Image
    [Attachment 47630 - Click to enlarge]

    Based on this calculations a rectangle is mapped to something like this:
    Image
    [Attachment 47631 - Click to enlarge]

    My philosophy has been mapping the center of the circle to all points of the bottom of the destination rectangle and mapping the area points of the circle to points of the top of the destination rectangle. With this philosophy, we can't reach to the rectangles shown in the YT video, especially when the rectangle is near to the center of the circle. So, it seems not to be right. I also doubt that I could implement the philosophy correctly by the code (It may need reviews).
    So, it seems that the steps may be divided into:
    A. Try to reach a correct panoramic image. This may need the steps I described in my previous reply as what I'm going to avoid. That's using OpenCV to calibrate and then give the non-distorted panoramic image.
    B. Try to find shapes (distorted rectangles) that when map to the panoramic image lead to a reasonable rectangular non-distorted image. How to calculate such a shape is of discussion.
    If I'm mistaking somehow, correct me please. If now, give me a way to achieve this. I would be happy if a more straightforward and simpler way exists and be shown.
    Now reviewing again your last post;
    1. You said that you could obtain exactly what (the output) provided by YT link? If so, it's excellent. Please give me the code if it's okay. Then we'll discuss about it.
    2. You said that all functionality of an application should be done on the obtain correct panoramic image? If so, section A gets more important.
    3. I meant being the same with what we see in real life with "adaptation". Matching I meant.
    4. Your second paragraph insists on the correctness of section B.
    I hope with your help I can reach of what I see in the YT video.
    Thanks
    Quote Quote  
  13. Originally Posted by hamidi2 View Post
    First of all, let's obtain a common literature. Since my mother tongue is not English, I may use improper words like adaptable. Let me describe what I got as well as what I need.

    snip here

    So, it seems that the steps may be divided into:
    A. Try to reach a correct panoramic image. This may need the steps I described in my previous reply as what I'm going to avoid. That's using OpenCV to calibrate and then give the non-distorted panoramic image.
    B. Try to find shapes (distorted rectangles) that when map to the panoramic image lead to a reasonable rectangular non-distorted image. How to calculate such a shape is of discussion.
    If I'm mistaking somehow, correct me please. If now, give me a way to achieve this. I would be happy if a more straightforward and simpler way exists and be shown.
    Now reviewing again your last post;
    1. You said that you could obtain exactly what (the output) provided by YT link? If so, it's excellent. Please give me the code if it's okay. Then we'll discuss about it.
    2. You said that all functionality of an application should be done on the obtain correct panoramic image? If so, section A gets more important.
    3. I meant being the same with what we see in real life with "adaptation". Matching I meant.
    4. Your second paragraph insists on the correctness of section B.
    I hope with your help I can reach of what I see in the YT video.
    Thanks
    At first English is also not native to me.

    Once again - seem you are missing most important part - resolution, sampling density must be sufficiently high in this area (centre) - for example human eye (fovea) matching this principle by two things - non uniform density of light receptors in fovea (centre more dense) and secondly they are also distributed randomly (unequally spaced). If your sensor can't mimic fovea then you must provide sufficiently high density in uniform way (waste of silicone but...) we talking about not 10 but rather 100++ Mega Pixels cameras. For sure there is why this YT movie looks so nicely - it can be even marketing material designed backward (so rendered on sphere normal very wide-angle/panoramic video).
    Quote Quote  
  14. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    There is more than one type of fisheye lens projection. You must first determine which projection is employed by this Bosch lens before you can reproject it.

    http://michel.thoby.free.fr/Fisheye_history_short/Projections/Various_lens_projection.html
    http://michel.thoby.free.fr/Fisheye_history_short/Projections/Models_of_classical_projections.html
    Quote Quote  
  15. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    The links you provided seem to be for someone who is too professional in this context, while I'm too newbie. For this I come and post to this section of forum. If the image I posted above (the left side one in the form) can't determine the lens type, I've no other information about it
    Quote Quote  
  16. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by hamidi2 View Post
    The links you provided seem to be for someone who is too professional in this context, while I'm too newbie.
    Then you are not the right person to write the program, I'm afraid.
    Quote Quote  
  17. Member
    Join Date
    Apr 2008
    Location
    Iran, Islamic Republic of
    Search Comp PM
    I'm not going to program it. I just need to use a ready-to-use library.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!