How can I correctly apply the scalar calibration of vector magnetometers? - matlab

I need to calibrate a magnetometer using the method of Merayo with matlab.
I have found this code:
But I do not understand how I apply this technique. I fact I have the magnetic Data distorted, I apply the Magnetic Calibration.
[U,c] = MgnCalibration(X)
So I get U the Shape ellipsoid parameter and c the ellipsoid center.
And the calibrated measurement is:
w = U*(v-c)
The problem is that when I calculate the corrected Data I have another order of values.
Data=[1750 1460 -3940]
CalibratedData=[0.4042 0.3820 -0.6860]
What I did not very well understood?
How can I use my magnetic data after this calibration?

The calibrated data for each axis [mx=0.4042 my=0.3820 mz=-0.6860] should now be independent of the orientation in 3D space in which the fluxgate finds itself for that specific measurement at that point in space. The Total Field calculated with sqrt(mx.mx+my.my+mz.mz) will be the calibrated Earth's Total magnetic field at that point.
If scaled properly this total field value should be the same as that measured by a proton or cesium vapor magnetometer

Related

Calculation vibration with accelerometer (LSM303D sensor)with STM32

I want to write an algorithm for ageing or condition monitoring of fluid valves.I read something about condition monitoring of valves and finally, I decided to calculate the vibration of the valve with accelerometer sensor.
Currently, I am working with LSM303D and ADXL345 sensors.
I am getting raw data from this sensor(LSM303D) like
X-axis = -2587 negative
Y -axis = -2230 negative
Z - axis = 16063
Is this mean acceleration is in Z axis direction?
I have fixed my sensor on the valve(There is no physical movement) and want to measure the vibration while switching on and off the valve.
How to proceed with my raw data for creating an algorithm for vibration calculation with STM32 controller?
Please explain about the raw data from sensor.
Sensor Datasheet
http://www.st.com/content/ccc/resource/technical/document/datasheet/1c/9e/71/05/4e/b7/4d/d1/DM00057547.pdf/files/DM00057547.pdf/jcr:content/translations/en.DM00057547.pdf
STM32 Datasheet:
http://www.st.com/content/ccc/resource/technical/document/datasheet/95/3c/2e/5b/21/09/45/a6/DM00115237.pdf/files/DM00115237.pdf/jcr:content/translations/en.DM00115237.pdf
OutPUT:
X axis
-2320,-2288,-2290,-2273,-2308,-2264,-2258,-2302,-2361,-2361,-2263,-2349,-2338,-2301,-2383,-2311,-2313,-2313,-2354,-2351,-2358,-2254,-2411,-2336,-2336,-2269,-2232,-2354,-2300,-2356,-2326,-2368,-2368,-2295,-2370,-2345,-2344,-2342,-2323,-2323,-2341,-2290,-2292,-2328,-2363,-2347,-2347,-2303,-2330,-2384,-2306,-2318,-2348,-2348,-2289,-2300,-2384,-2301,-2269,-2269,-2391,-2314,-2294,-2327,-2343,-2331,-2331,-2247,-2313,-2403,-2284,-2336,-2336,-2323,-2340,-2276,-2277,-2353,-2400,-2400,-2321,-2296,-2317,-2314,-2356,-2359,-2359,-2313,-2250,-2312,-2334,-2314,-2314,-2298,-2317,-2279,-2368,-2331,-2560,-2304,-2298,-2327,-2301,-2332,-2330,-2330,-2269,-2300,-2300,-2332,-2271,-2057,-2313,-2316,-2309,-2257,-2362,-2406,-2406,-2290,-2298,-2373,-2314,-2260,-2277,-2277,-2323,-2332,-2189,-2314,-2339,-2553,-2297,-2332,-2327,-2289,-2347,-2326,-2326,-2319,-2361,-2330,-2352,-2329,-2550,-2294,-2311,-2312,-2327,-2344,-2362,-2360,-2280,-2307,-2307,-2370,-2307,-2211,-2264,-2313,-2354,-2317,-2344,-2352,-2288,-2288,-2266,-2307,-2297,-2356,-2334,-2302,-2307,-2307,-2326,-2289,-2345,-2387,-2378,-2308,-2308,-2323,-2323,-2273,-2348,-2288,-2288,-2314,-2255,-2299,-2335,-2306,-2327,-2327,-2267,-2313,-2319,-2275,-2307,-2354,-2354,-2299,-2288,-2279,-2337,-2325,-2325,-2256,-2312,-2294,-2295,-2294,-2368,-2368,-2326,-2324,-2320,-2303,-2310,-2325,-2325,-2310,-2291,-2309,-2328,-2364,-2364,-2284,-2354,-2376,-2311,-2335,-2342,-2342,-2336,-2322,-2317,-2276,-2385,-2362,-2268,-2107,-2363,-2307,-2292,-2296,-2356,-2288,-2288,-2355,-2372,-2303,-2348,-2279,-2346,-2346,-2238,-2320,-2323,-2280,-2318,-2345,-2345,-2318,-2323,-2316,-2316,-2307,-2324,-2324,-2376,-2251,-2347,-2375,-2300,-2300,-2399,-2318,-2283,-2375,-2356,-2316,-2316,-2260,-2418,-2341,-2347,-2327,-2327,-2308,-2358,-2335,-2344,-2350,-2264,-2264,-2377,-2328,-2323,-2347,-2351,-2352,-2352,-2290,-2369,-2307,-2333,-2306,-2540,-2284,-2343,-2353,-2283,-2301,-2310,-2548,-2292,-2358,-2321,-2275,-2290,-2267,-2267,-2378,-2330,-2319,-2356,-2315,-2337,-2337,-2360,-2385,-2358,-2320,-2304,-2290,-2290,-2329,-2362,-2318,-2335,-2303,-2303,-2358,-2305,-2293,-2288,-2244,-2255,-2255,-2339,-2337,-2375,-2296,-2243,-2053,-2309,-2346,-2410,-2333,-2287,-2316,-2316,-2362,-2331,-2291,-2350,-2394,-2323,-2323,-2377,-2313,-2324,-2327,-2322,-2322,-2258,-2325,-2356,-2337,-2376,-2351,-2351,-2286,-2255,-2347,-2376,-2359,-2343,-2343,-2389,-2303,-2302,-2384,-2298,-2298,-2313,-2344,-2323,-2273,-2295,-2316,-2316,-2369,-2343,-2287,-2280,-2348,-2544,-2288,-2279,-2380,-2349,-2241,-2344,-2344,-2366,-2363,-2350,-2303,-2335,-2340,-2340,-2309,-2348,-2304,-2354,-2644,-2461,-2404,-2404,-2170,-2374,-2299,-2268,-2334,-2334,-2364,-2288,-2337,-2329,-2401,-2241,-2241,-2247,-2339,-2395,-2312,-2369,-2526,-2270,-2298,-2318,-2285,-2254,-2316,-2349,-2349,-2334,-2274,-2297,-2352,-2321,-2321,-2293,-2358,-2289,-2341,-2329,-2336,-2336,-2360,-2311,-2345,-2344,-2321,-2321,-2333,-2285,-2284,-2325,-2360,-2280,-2280,-2303,-2343,-2237,-2317,-2373,-2535,-2279,-2309,-2287,-2308,-2289,-2334,-2334,-2293,-2330,-2315,-2271,-2300,-2346,-2346,-2336,-2287,-2308,-2320,-2315,-2347,-2347,-2302,-2283,-2267,-2312,-2288,-2096,-2352,-2298,-2252,-2290,-2341,-2328,-2290,-2290,-2265,-2242,-2326,-2262,-2300,-2074,-2330,-2322,-2382,-2304,-2316,-2337,-2337,-2209,-2358,-2339,-2285,-2319,-2280,-2280,-2327,-2299,-2329,-2331,-2317,-2347,-2347,-2343,-2334,-2255,-2295,-2295,-2295,-2315,-2343,-2365,-2366,-2326,-2542,-2286,-2331,-2343,-2370,-2317,-2291,-2270,-2270,-2343,-2261,-2335,-2343,-2297,-2297,-2359,-2290,-2293,-2350,-2314,-2315,-2315,-2388,-2357,-2335,-2382,-2235,-2052,-2308,-2379,-2340,-2313,-2260,-2301,-2301,-2225,-2323,-2286,-2383,-2370,-2504,-2248,-2274,-2317,-2282,-2285,-2226,-2145,-2401,-2341,-2361,-2422,-2336,-2288,-2288,-2386,-2357,-2294,-2310,-2295,-2117,-2373,-2260,-2274,-2289,-2379,-2313,-2313,-2256,-2300,-2344,-2293,-2296,-2312,-2312,-2363,-2328,-2347,-2351,-2294,-2092,-2348,-2381,-2347,-2229,-2275,-2328,-2328,-2379,-2256,-2362,-2331,-2347,-2360,-2360,-2279,-2269,-2332,-2374
Y Axis
-2485,-2478,-2511,-2486,-2486,-2475,-2490,-2517,-2482,-2505,-2457,-2457,-2468,-2471,-2475,-2498,-2513,-2489,-2531,-2531,-2509,-2435,-2473,-2493,-2486,-2428,-2428,-2485,-2473,-2513,-2459,-2514,-2510,-2456,-2456,-2519,-2511,-2569,-2466,-2484,-2524,-2524,-2475,-2468,-2518,-2469,-2443,-2513,-2513,-2494,-2460,-2503,-2466,-2497,-2497,-2460,-2472,-2528,-2473,-2479,-2480,-2480,-2448,-2425,-2447,-2523,-2552,-2447,-2447,-2513,-2532,-2480,-2459,-2511,-2511,-2493,-2472,-2447,-2477,-2542,-2434,-2434,-2472,-2484,-2477,-2503,-2472,-2472,-2478,-2519,-2501,-2449,-2453,-2477,-2477,-2491,-2471,-2480,-2507,-2473,-2449,-2449,-2514,-2457,-2473,-2513,-2501,-2501,-2437,-2520,-2479,-2481,-2468,-2497,-2497,-2523,-2488,-2454,-2525,-2470,-2470,-2448,-2487,-2484,-2477,-2460,-2476,-2476,-2515,-2467,-2443,-2449,-2480,-2480,-2451,-2459,-2470,-2477,-2489,-2463,-2463,-2492,-2500,-2469,-2491,-2475,-2528,-2528,-2438,-2442,-2506,-2499,-2489,-2461,-2486,-2485,-2483,-2492,-2523,-2453,-2453,-2484,-2458,-2509,-2484,-2497,-2433,-2433,-2515,-2479,-2507,-2519,-2485,-2483,-2500,-2500,-2477,-2510,-2506,-2488,-2480,-2497,-2497,-2488,-2464,-2452,-2496,-2487,-2487,-2512,-2464,-2489,-2484,-2496,-2477,-2477,-2467,-2478,-2500,-2452,-2534,-2490,-2490,-2499,-2485,-2463,-2457,-2501,-2501,-2471,-2448,-2524,-2480,-2473,-2503,-2503,-2481,-2525,-2497,-2449,-2511,-2483,-2483,-2513,-2459,-2501,-2462,-2489,-2489,-2496,-2494,-2468,-2453,-2464,-2537,-2537,-2484,-2520,-2442,-2514,-2505,-2463,-2517,-2523,-2523,-2471,-2454,-2444,-2442,-2519,-2519,-2521,-2480,-2457,-2455,-2492,-2471,-2471,-2454,-2493,-2510,-2480,-2458,-2489,-2489,-2485,-2492,-2487,-2459,-2466,-2466,-2519,-2446,-2500,-2527,-2459,-2489,-2489,-2479,-2469,-2484,-2482,-2477,-2480,-2480,-2479,-2494,-2514,-2485,-2474,-2474,-2493,-2505,-2495,-2471,-2496,-2501,-2501,-2438,-2495,-2469,-2488,-2481,-2521,-2521,-2508,-2490,-2465,-2480,-2455,-2524,-2524,-2499,-2502,-2481,-2472,-2490,-2490,-2432,-2494,-2543,-2478,-2462,-2487,-2487,-2525,-2491,-2500,-2491,-2449,-2490,-2490,-2459,-2506,-2476,-2487,-2493,-2480,-2480,-2498,-2472,-2506,-2473,-2457,-2457,-2503,-2515,-2479,-2486,-2482,-2521,-2521,-2491,-2509,-2505,-2496,-2483,-2483,-2453,-2495,-2519,-2440,-2548,-2482,-2482,-2427,-2532,-2495,-2466,-2436,-2443,-2443,-2500,-2444,-2458,-2455,-2489,-2489,-2510,-2497,-2494,-2510,-2519,-2485,-2485,-2458,-2509,-2466,-2519,-2483,-2523,-2523,-2482,-2511,-2492,-2463,-2470,-2470,-2494,-2481,-2487,-2495,-2493,-2513,-2513,-2490,-2495,-2505,-2476,-2470,-2470,-2480,-2502,-2479,-2420,-2470,-2479,-2479,-2491,-2530,-2512,-2503,-2538,-2446,-2446,-2447,-2562,1029,-2413,-2366,-2607,-2607,-2426,-2440,-2552,-2446,-2503,-2517,-2517,-2428,-2496,-2462,-2489,-2525,-2513,-2513,-2456,-2476,-2500,-2535,-2524,-2453,-2453,-2534,-2493,-2480,-2487,-2437,-2437,-2470,-2514,-2465,-2532,-2511,-2448,-2448,-2479,-2532,-2519,-2507,-2463,-2510,-2510,-2459,-2461,-2483,-2488,-2520,-2520,-2485,-2455,-2491,-2492,-2445,-2458,-2458,-2477,-2489,-2492,-2478,-2506,-2501,-2501,-2489,-2485,-2481,-2480,-2486,-2486,-2471,-2453,-2505,-2473,-2478,-2472,-2472,-2493,-2487,-2491,-2479,-2492,-2518,-2518,-2520,-2508,-2503,-2465,-2501,-2488,-2488,-2485,-4231,-2508,-2483,-2376,-2474,-2474,-2453,-2503,-2498,-2455,-2495,-2495,-2495,-2517,-2455,-2470,-2441,-2478,-2478,-2470,-2500,-2484,-2473,-2418,-2477,-2477,-2512,-2459,-2503,-2473,-2464,-2476,-2476,-2480,-2497,-2499,-2501,-2492,-2492,-2443,-2478,-2500,-2476,-2486,-2529,-2529,-2455,-2521,-2463,-2482,-2460,-2460,-2510,-2506,-2470,-2484,-2473,-2441,-2441,-2500,-2489,-2502,-2496,-2415,-2504,-2504,-2518,-2417,-2500,-2498,-2460,-2501,-2501,-2498,-2460,-2449,-2465,-2499,-2499,-2496,-2479,-2521,-2513,-2513,-2479,-2479,-2480,-2546,-2514,-2502,-2479,-2479,-2446,-2484,-2531,-2524,-2533,-2489,-2489,-2486,-2444,-2477,-2462,-2474,-2513,-2513,-2485,-2475,-2463,-2438,-2477,-2477,-2470,-2481,-2467,-2497,-2454,-2475,-2475,-2507,-2477,-2499,-2464,-2501,-2501,-2523,-2502,-2452,-2497,-2488,-2456,-2456,-2487,-2504,-2490,-2472,-2547,-2458,-2458,-2469,-2429
Z Axis:
16068,16050,16097,16178,16142,16294,16038,16070,16184,16207,16125,16174,16246,16246,16161,16117,16132,16128,16104,16281,16326,16070,16012,16147,16174,15961,16097,16121,15919,16175,16173,16092,16019,16144,16074,16136,16136,16031,16016,16123,16077,16166,16019,16019,16169,16132,16150,16075,16100,15896,16152,16047,16215,16183,16040,16178,16178,16127,16099,16035,16169,16243,16323,16067,16150,16071,16144,16052,16118,15931,16187,16242,16096,16243,16090,16170,16170,16108,16137,16060,16081,16184,16323,16067,16078,16148,16104,16011,16174,16174,16123,16133,16196,16109,16117,16088,16088,16159,16153,16112,16127,16215,16215,16064,16046,16073,16081,16141,16351,16095,16143,16171,16145,16081,16226,16339,16083,16078,16209,15997,16071,16181,16181,16128,16070,16077,16018,16163,16293,16037,16146,16207,16147,16041,16124,16124,16093,16129,15987,16152,16175,16311,16055,16114,16116,16245,16052,16125,16148,16111,16111,16157,16040,15968,16174,16213,16106,16052,16161,16048,16142,16142,16147,16030,16102,16079,16153,16178,16129,16179,16179,16079,16060,16020,16103,16074,16078,16078,16164,16182,16163,16105,16046,16046,16160,16068,16060,16074,16125,16131,16131,16160,16026,16019,16153,16048,15924,16180,16087,16150,16048,16072,16040,16040,16139,16106,16077,16262,16117,16212,16212,16239,16043,16219,16119,16012,16105,16105,16111,16044,16161,16073,16020,16020,16135,16160,16096,16076,16110,16053,16053,16151,16066,16068,16129,16123,16114,15886,16142,16199,16181,16064,16090,16043,16099,16099,16128,16058,16016,16043,16167,16177,16177,16010,16158,16086,16112,16115,15888,16144,16135,16226,16110,16121,16053,15916,16172,16075,16061,16119,16137,16159,16159,16181,16075,16039,16242,16121,15977,15977,16141,16155,16207,16069,16107,16107,16114,16083,16102,16008,16071,16119,16119,16028,16124,16225,16022,16134,16130,16130,16137,16174,16086,16159,16056,16088,16088,16186,16154,16050,16092,16159,16146,16146,16070,16176,16225,16088,16118,16118,16093,16289,16118,16091,16141,16207,16207,16173,16151,16048,16195,16141,16202,16202,16058,16040,16145,16190,16140,16140,16159,16163,16153,16151,16106,16178,16178,16044,16064,16223,16131,16101,15955,16211,16151,16161,15998,16099,16053,16053,16085,16005,16134,16144,16088,15872,16128,16072,16029,16230,16109,16039,16081,16081,16267,16176,16049,16156,16162,16162,16130,16138,16018,16119,16180,16129,16129,16178,16091,16108,16169,16191,16191,16064,16070,16117,16160,16110,16082,16082,16096,15991,16130,16194,16068,15930,15930,16132,16121,16067,16105,16087,16087,16183,16269,16118,15998,16180,16129,16129,16128,16156,16166,16065,16136,16248,16248,11913,15882,16067,16164,16004,16159,16159,16201,16050,16129,16144,16119,16129,16129,16028,16126,16152,16117,16107,15903,16159,16138,16140,16131,16075,16110,15895,16151,16064,16168,16116,16131,16160,16160,16150,16130,16059,16141,16128,16195,16195,16216,16053,16097,16167,16122,16122,16077,16173,16031,16131,16092,16099,16099,16163,16126,16065,16137,16165,16342,16086,16050,16156,16087,16107,16169,16169,16178,16061,16091,16061,16260,16133,16133,16117,16174,16108,16164,16162,16311,16055,16219,16143,16127,16105,16121,15902,16158,16194,16044,16178,16057,16085,15329,15329,16090,16066,16131,16113,16163,16352,16096,16080,16057,16111,16146,16134,16134,16162,16092,16139,16120,16144,16028,16028,16142,16171,16066,16041,16154,16366,16110,16110,16128,16117,16125,16091,16091,16149,16050,16024,16154,16186,16072,16072,16090,16143,16206,16141,16073,16052,16052,16123,16158,16159,16197,16135,16135,16119,16128,16090,16063,16139,16153,16153,16019,16072,16128,16153,16129,16180,16180,16157,16207,16126,16158,16066,16066,16102,16177,16104,16202,16104,16159,16159,16090,16071,16070,16115,16127,15924,16180,16088,16122,16075,16085,16105,16105,16187,16056,16010,16150,16151,16166,16166,16124,16088,16166,16123,15991,15944,16200,16124,16152,16093,16106,16057,16057,16177,16163,16167,16021,16095,16106,16106,16088,16170,16162,16144,16266,16266,16115,16135,16159,16021,16240,16162,16162,16004,16154,16182,16073,16129,16299
The reference is relative to the chip position. See the datasheet for this.
Don't forget that gravity is an acceleration, so when the accelerometer is still, the output vector points downwards (in the Earth reference). You can store an initial value (an average on several points in the best case), and substract this value from your datapoints.
The best way to debug this is to plot the values in real time.

Verify that camera calibration is still valid

How do you determine that the intrinsic and extrinsic parameters you have calculated for a camera at time X are still valid at time Y?
My idea would be
to use a known calibration object (a chessboard) and place it in the camera's field of view at time Y.
Calculate the chessboard corner points in the camera's image (at time Y).
Define one of the chessboard corner points as world origin and calculate the world coordinates of all remaining chessboard corners based on that origin.
Relate the coordinates of 3. with the camera coordinate system.
Use the parameters calculated at time X to calculate the image points of the points from 4.
Calculate distances between points from 2. with points from 5.
Is that a clever way to go about it? I'd eventually like to implement it in MATLAB and later possibly openCV. I think I'd know how to do steps 1)-2) and step 6). Maybe someone can give a rough implementation for steps 2)-5). Especially I'd be unsure how to relate the "chessboard-world-coordinate-system" with the "camera-world-coordinate-system", which I believe I would have to do.
Thanks!
If you have a single camera you can easily follow the steps from this article:
Evaluating the Accuracy of Single Camera Calibration
For achieving step 2, you can easily use detectCheckerboardPoints function from MATLAB.
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
Assuming that you are talking about stereo-cameras, for stereo pairs, imagePoints(:,:,:,1) are the points from the first set of images, and imagePoints(:,:,:,2) are the points from the second set of images. The output contains M number of [x y] coordinates. Each coordinate represents a point where square corners are detected on the checkerboard. The number of points the function returns depends on the value of boardSize, which indicates the number of squares detected. The function detects the points with sub-pixel accuracy.
As you can see in the following image the points are estimated relative to the first point that covers your third step.
[The image is from this page at MATHWORKS.]
You can consider point 1 as the origin of your coordinate system (0,0). The directions of the axes are shown on the image and you know the distance between each point (in the world coordinate), so it is just the matter of depth estimation.
To find a transformation matrix between the points in the world CS and the points in the camera CS, you should collect a set of points and perform an SVD to estimate the transformation matrix.
But,
I would estimate the parameters of the camera and compare them with the initial parameters at time X. This is easier, if you have saved the images that were used when calibrating the camera at time X. By repeating the calibrating process using those images you should get very similar results, if the camera calibration is still valid.
Edit: Why you need the set of images used in the calibration process at time X?
You have a set of images to do the calibrations for the first time, right? To recalibrate the camera you need to use a new set of images. But for checking the previous calibration, you can use the previous images. If the parameters of the camera are changes, there would be an error between the re-estimation and the first estimation. This can be used for evaluating the validity of the calibration not for recalibrating the camera.

Understanding depth values in 3D point cloud

I have problems understanding the depth (Z) value in 3D point cloud resulted from 3d sparse reconstruction like this example in MATLAB: http://www.mathworks.com/help/vision/ug/sparse-3-d-reconstruction-from-multiple-views.html
I have attached a picture showing the reconstructed 3D point cloud in the above example. I have put some datatips on the figure so we know the (x,y,z) coordinates of the points. here are my questions:
1- what does the Z value in point cloud represent? is it the distance in millimeters from the camera? if that's the case then it does not make sense based on the picture I attached since I am sure the distance of the sphere and checkerboard from the camera must be greater than 200 mm.
Or maybe it is from some reference point in space? then what is this reference point? and how can I make a 3D point cloud that the Z values indicate the distance from the camera?
2- why is there negative values for Z? what does that mean in terms of distance to the camera?
I appreciate if someone can explain.
In this example the world coordinates are defined by the checkerboard. The checkerboard defines the X-Y plane, and the Z-axis points into the checkerboard, as explained in the documentation:
Since your 3D points are above the checkerboard, they have negative Z-coordinates.
Your (x,y,z) coordinates are in world units, which are completely disconnected from metric values (unless you build a scale between world and metric, there are various methods to do it). So the z value tells you about the depth of each point in world coordinates.
If you have the pose of each camera, and you multiply each point by the camera projection matrix, you will get the (x',y',z') points in camera coordinates. At that point, if z' is negative, it means it's behind the camera.

Stereo matching

I am using Camera Calibration Toolbox for Matlab. After calibration I have intrinsic and extrinsic parameters of stereo camera system. Next, I would like to determine the distance between the camera system and the object. To get this information, I used the function stereo_triangulation which is included in the Toolbox. Input are two matrixes including pixel coordinates of correspondences in the left and right image.
I tried to get coordinates of correspondences with using of Basic Block Matching method which is described in Matlab's help for Stereo Vision.
Resolution of my pictures is 1280x960 pixels. I know that the biggest disparity is around 520 pixels. I set the maximum of disparity range to 520. But then determine the coordinates takes ages. It is not possible use in practice. Calculating of disparity map is much faster with using of Matlab's function disparity(). But I want the step before - coordinates of correspondences.
Please can you suggest how can I effectively get the coordinates with Matlab?
Disparity and 3D are related by simple formulas (see below) so the time for calculating 3D data and disparity map should be the same. The notation is
f - focal length in pixels,
B - separation between cameras,
u, v - row and column in the system centered on the middle of the image,
d-disparity,
x, y, z - 3D coordinates.
z=f*B/d;
x=z*u/f;
y=z*v/f;
1280x960 is too large resolution for any correlation stereo to work in real time. Think about it: you have to loop over a 2d image, over 2d correlation window and over the range of disparities. This means 5 embedded loops! I don't work with Matlab anymore but I know that it is quite slow.

pca in matlab - 2D curve stretching

I have N 3D observations taken from an optical motion capture system in XYZ form.
The motion that was captured was just a simple circle arc, derived from a rigid body with fixed axis of rotation.
I used the princomp function in matlab to get all marker points on the same plane i.e. the plane on which the motion has been done.
(See a pic representing 3D data on the plane that was found, below)
What i want to do after the previous step is to look the fitted data on the plane that was found and get the curve of the captured motion in 2D.
In the princomp how to, it is said that
The first two coordinates of the principal component scores give the
projection of each point onto the plane, in the coordinate system of
the plane.
(from "Fitting an Orthogonal Regression Using Principal Components Analysis" article on mathworks help site)
So i thought that if i just plot those pc scores -plot(score(:,1),score(:,2))- i'll get the motion curve. Instead what i got is this.
(See a pic representing curve data in 2D derived from pc scores, below)
The 2d curve seems stretched and nonlinear (different y values for same x values) when it shouldn't be. The curve that i am looking for, should be interpolated by just using simple polynomial (polyfit) or circle fit in matlab.
Is this happening because the plane that was found looks like rhombus relative to the original coordinate system and the pc axes are rotated with respect to the basis of plane in such way that produce this stretch?
Then i thought that, this is happening because of the different coordinate systems of optical system and Matlab. Optical system's (ie cameras) co.sys. is XZY oriented and Matlab's default (i think) co.sys is XYZ oriented. I transformed my data to correspond to Matlab's co.sys through a rotation matrix, run again princomp but i got the same stretch in the 2D curve (the new curve just had different orientation now).
Somewhere else i read that
Principal Components Analysis chooses the first PCA axis as that line
that goes through the centroid, but also minimizes the square of the
distance of each point to that line. Thus, in some sense, the line is
as close to all of the data as possible. Equivalently, the line goes
through the maximum variation in the data. The second PCA axis also
must go through the centroid, and also goes through the maximum
variation in the data, but with a certain constraint: It must be
completely uncorrelated (i.e. at right angles, or "orthogonal") to PCA
axis 1.
I know that i am missing something but i have a problem understanding why i get a stretched curve. What i have to do so i can get the curve right?
Thanks in advance.
EDIT: Here is a sample data file (3 columns XYZ coords for 2 markers)
w w w.sendspace.com/file/2hiezc