Ask Your Question

n.argirop's profile - activity

2017-02-25 06:54:28 -0600 asked a question Increased Reprojection Error from Chessboard Calibration

So, I have written a script that performs chessboard calibration and the reprojection error I get is always greater than 1.3-1.5 pixels, even though the calibration parameters are correct (except the principal point coordinates, but that's expected). I couldn't find a reason why this is happening and then I thought to try it by photographing the target with lower camera resolution, since many of the forum threads I found were talking about less than 0.5 pixel error with low resolution cameras (640x480 pix) and I was using DSLRs with 6-7 times this resolution. After this attempt the error was indeed lower than 1 pixel but still a little too high. Then, I downsampled the images to 640x480 resolution and the error now had the expected and desired values of less than 0.4-0.5 pixels. Any ideas why this is happening?

P.S. The script is written in Python and I am using subpixel refinement for the detected chessboard corners.

2016-09-09 12:21:50 -0600 commented question Change pixel x,y location with mathematical function

@kbarni Thanks for the reply! I thought about after I posted my question and tried it but the differences are -if not zero- at least very small (maybe less than a second).

2016-09-09 09:47:39 -0600 asked a question Change pixel x,y location with mathematical function

As the title suggests, I have an image, whose pixels I want to move based on a mathematical function. The code I use right now is consisted of two loops. And because of the nested loop, the process takes forever, -to be exact more than two minutes most of the times-, having in mind that each image has 12000 pixels to run through the loops. Is there another way to do this? I looked through the documentation but couldn't find anything.

imgcor = np.zeros(img.shape, dtype=img.dtype)
                for f in range(rowc):
                    for k in range(colc):
                        offX = k + (f*b*c*(math.sin(math.radians(a))))
                        offY = f + (f*b*d*(math.cos(math.radians(a))))
                        imgcor[f, k] = img[int(offY)%rowc, int(offX)%colc]

The a,b,c,d values are certain parameters that are assigned earlier in the script.

P.S. I am using Python2.7 and opencv 2.4

2016-08-16 10:19:58 -0600 received badge  Enthusiast
2016-08-15 15:26:19 -0600 commented question Change 0,0 image point

It exceeds the character limit.

2016-08-15 15:19:55 -0600 commented question Change 0,0 image point

You can find the code here

2016-08-15 11:43:50 -0600 commented question Change 0,0 image point

I am basically trying to calculate the camera translation vector (magnitude and direction) by matching SURF points between two images. The problem I have is when I try to calculate the vector angle by using the arctangent.

2016-08-15 11:06:30 -0600 asked a question Change 0,0 image point

Is it possible to change the 0,0 image point? I know it is located at the top left corner of the image and because of the fact that the axes continue with positive values downwards it makes it a little hard for me to perform some operations on the image points.

Thank you very much!

2016-07-21 13:09:06 -0600 commented question Image matching using goodFeaturesToTrack

Thank you very much!

2016-07-20 12:04:41 -0600 asked a question Image matching using goodFeaturesToTrack

I already tried to detect corners using goodFeaturesToTrack and then use those corners in BFMatcher, which doesn't accept them and asks for keypoints instead. Is it possible to make it work somehow? The reason why I don't use SIFT, SURF, etc. is because of the calculation speed and the fact that I can manipulate the dispersion of the points on the image, thus being able to use much fewer points to achieve a good dispersion on the whole image.

I am using opencv 2.4.13 and python 2.7

2016-07-17 09:30:43 -0600 commented question Python - Undistort script won't work

The excel file and an image sample can be found here

2016-07-17 09:23:52 -0600 commented question Python - Undistort script won't work

You are right. I just changed it though and it still doesn't work.

2016-07-17 08:43:46 -0600 asked a question Python - Undistort script won't work

I wrote the following script to undistort multiple photos in one go by defining a containing folder. Because of the fact that the camera I am using is calibrated professionally and all of the intrinsic and distortion parameters are known, I have specified a camera matrix and the distortion coefficients. The script runs without any errors but the output images are exactly the same as the original-distorted images. There is no way that the changes are difficult to detect since I am using a GoPro camera with the (in)famous fisheye distortion. Here is the script:

#Modules
import os
from os import listdir
from os.path import isfile, join
import cv2
import numpy as np
from xlrd import open_workbook,cellname
from xlutils.copy import copy

#Excel file loading
filepath = str(raw_input("\nEnter Excel file path (e.g. C:/Users/user/Desktop): "))
os.chdir(filepath)
filename = str(raw_input("\nEnter Excel file name (e.g. camera.xls): "))

#Excel file values
rb = open_workbook(filepath+filename,formatting_info=True)
r_sheet = rb.sheet_by_index(0)
wb = copy(rb)
sheet = wb.get_sheet(0)
psize = r_sheet.cell(0,0).value #Pixel pitch
focal = r_sheet.cell(0,1).value #Focal length in mm
pixden = 1/psize #Sensor pixels/mm
fx = pixden*f
fy = pixden*f
cx = r_sheet.cell(0,2).value #P.P. x-offset
cy = r_sheet.cell(0,3).value #P.P. y-offset
k1 = r_sheet.cell(0,4).value
k2 = r_sheet.cell(1,4).value
k3 = r_sheet.cell(2,4).value
k4 = r_sheet.cell(3,4).value
k5 = r_sheet.cell(4,4).value
k6 = r_sheet.cell(5,4).value
p1 = r_sheet.cell(0,5).value
p2 = r_sheet.cell(0,6).value

#Camera Matrix
cammat = np.zeros((3, 3), dtype=np.float32)
cammat[0,0] = fx
cammat[0,1] = 0
cammat[0,2] = cx
cammat[1,0] = 0
cammat[1,1] = fy
cammat[1,2] = cy
cammat[2,0] = 0
cammat[2,1] = 0
cammat[2,2] = 0

#Distortion Coefficients Vector
radd = np.zeros((4,1), np.float64)
radd[0,0] = k1
radd[1,0] = k2
radd[2,0] = p1
radd[3,0] = p2

#Load all images in the specified directory
imgpath = str(raw_input("\nEnter image path (e.g. C:/Users/user/Desktop): "))
os.chdir(imgpath)
allimgfiles = [f for f in listdir(imgpath) if isfile(join(imgpath,f))]
images = np.empty(len(allimgfiles), dtype=object)

#Apply undistortion
for n in range(0, len(allimgfiles)):
    images[n] = cv2.imread(join(imgpath, allimgfiles[n]))
    dimg = cv2.imread("E:/DSC06786.JPG")
    udimg = cv2.undistort(dimg, cammat, radd, None)

    #Save undistorted images
    cv2.imwrite("e:/undistorted.jpg", udimg)

    #Display undistorted image
    window_width = 1000
    window_height = 750
    cv2.namedWindow("Top 'k' features", cv2.WINDOW_NORMAL)
    cv2.resizeWindow("Top 'k' features", window_width, window_height)
    cv2.imshow("Top 'k' features", dimg)
    cv2.waitKey(0)

The intrinsic and distortion parameters are saved in an excel file as you will notice which I cannot upload unfortunately. The values are parsed correctly and it is not were the problem lies. I have quadraple checked if the excel file is the problem, but it is ... (more)