Want to try the Distance measurment for arducam stereo camera

@wong and also i made the UART serial communication, and my friend said this is enough.

and for the time sleep, i commented that because the image was lagging, how about this ? next, i need to make the UART for my STM32F4 right ? thank you

Hi @AldifaJulian

You need to make some modifications to stereovision:
step as follows:

  1. cd $(dirname $(python3 -c’import stereovision;print(stereovision.file)’))
  2. Modify calibration.py to comment out lines 266-269

  1. Recalibrate


@wong is that for the distance measurment right, but can you just send me the file ? i don’t have much time

@wong also i’m a bit confused here, for calibration.py there are no such things like that on mine, can you explain more ? thank you

excuse me @wong for the third part, for recallibrate what should i do ? is this when i run my program from the beginning (1_test.py) ? can you explain more ? thank you

hello @wong i already tried your steps but it turns out error like this after i tried 4_calibration.py, so what should i do ? please reply ASAP, I don’t have much time left, thank you

Hello @wong i still can’t find the answer about the error, what should i do ? please reply ASAP, thank you

hello @wong after i asked my friend he said that my data was correct from my new data the closer the object is, the smaller the value he said.

And i need to convert this xyz data to the cm distance after knowing the value of z (third value) by doing regression like this

so do you have a source code to regression the distance ? and what software should i need to install, please give the terminal commands ? please reply ASAP, i don’t have much time left before my final project, thank you

Hi @AldifaJulian

Sorry for the late reply,
Sorry, I don’t have a source code to regression the distance.
The attachment is the modified calibration.py,

you can replace it with calibration.py in the

dirname $(python3 -c ‘import stereovision;print(stereovision.file)’)


@wong So i need to replace the old one ?

@wong i don’t know how to replace file from terminal, i mean i got your file but i don’t know how to, can you explain more ? if i replace the file i’m afraid i’ll got the same error when i’m going to recalibrate, does this works on you, and please explain me more, thank you

Hi @AldifaJulian

After testing that this patch can fix the negative value problem, we measured the actual distance and it is correct.

You can use the previous picture to calibrate without re-shooting.

The replacement process is as follows:

  1. Download the calibration.zip attached to the Raspberry Pi and unzip it, you will get the calibration.py file
  2. Execute the command as follows to get the installation location of stereovision

dirname $(python3 -c ‘import stereovision;print(stereovision.file)’)

  1. Perform file replacement
    cp xxx/calibration.py /usr/local/lib/python3.6/dist-packages/stereovision/calibration.py
    (Your destination path may be different, please replace it with the path in step two)

@wong “cp xxx/calibration.py /usr/local/lib/python3.6/dist-packages/stereovision/calibration.py” is this the command for replacing file on terminal ?

@wong excuse me i have tried that but got access denied, even though i added sudo at the front, what should i do ? thank you

got message cp cannot create regular file no such file or directory raspberry pi

hello @wong i already solved my previous problem, and now for my current problem i want to convert the matrix data into the real distance data, my friend told me that the easiest way is to do regression, because after after knowing the value of z we can do regression, and the regression is to regression value to centimeter, that’s why i have openpyxl and sklearn for the software, can you help me how to convert or maybe you have another way ? please reply ASAP, thank you.


PS : this is my reference https://github.com/LearnTechWithUs/Stereo-Vision/blob/master/Main_Stereo_Vision_Prog.py and this is the video : https://www.youtube.com/watch?v=xjx4mbZXaNc

Hi @AldifaJulian

I can’t provide you with the help of custom code implementation, which is beyond the scope of our support.
However, as I said, if you apply the patch I introduced, then the current distance should be correct without additional conversion.

excuse me @wong i want to ask, something is bothering me about this data,first, are you sure it is corect enough ? because from what i check from the real measurment, it is around 40-50cm, and second one is this is matrix data (xyz) you said the third one is the distance data(z), is this data already in centimeters? and the third one, my friend told me if the object when the object is brought closer, the value gets smaller, but sometimes it becomes bigger, can you explain all of this ? please reply ASAP, thank you

PS : i took the nearest distance data for the object and the real measurement is for each steps of stairs

Hi @AldifaJulian

There is a minimum distance for stereo distance measurement. You can first try to measure a distance of more than one meter to confirm whether it is accurate. If the object you measure is less than the minimum distance, the measurement will be inaccurate.