Udayraj123/OMRChecker

Installing opencv on a fresh droplet : segmentation fault (core dumped)

Siva2406 opened this issue · 11 comments

Did the setup on Ubuntu 16.04 and ran the code with sample files available the repo. Please find the code I used.

sudo apt-get update -y
sudo apt-get upgrade -y
sudo reboot
python3 -m pip install --user --upgrade pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
python3 -m pip install --user --upgrade pip
python3 -m pip install --user opencv-python
python3 -m pip install --user opencv-contrib-python
git clone https://github.com/Udayraj123/OMRChecker
cd OMRChecker/
python3 -m pip install --user -r requirements.txt
sudo cp -r inputs/OMR_Files_Sample/ inputs/OMR_Files
python3 main.py

If I run the code, I am getting, "Segmentation fault (core dumped)" error.

Even I tried steps mentioned here to create custom layout template. But, whatever I do, I am getting "Segmentation fault (core dumped)" error.

It's an issue with file permissions. You have used sudo cp there. Remove the files and try again without sudo

Even after doing that, I am getting the same error. I have logged in as root and executed the command. Currently, following is the permission set for the files,
Untitled

Let me know what permission should I set to resolve the issue. Please find my cmds below,

1 sudo apt-get update -y
2 sudo apt-get upgrade -y
3 sudo reboot
4 wget https://bootstrap.pypa.io/get-pip.py
5 python3 get-pip.py
6 python3 -m pip install --user --upgrade pip
7 python3 -m pip install --user opencv-python
8 python3 -m pip install --user opencv-contrib-python
9 git clone https://github.com/Udayraj123/OMRChecker
10 cd OMRChecker/
11 python3 -m pip install --user -r requirements.txt
12 cp -r inputs/OMR_Files_Sample/ inputs/OMR_Files
13 python3 main.py

No need to login as root/Administrator! Execute all the commands as a normal user

I am running this on cloud machine with root privileges. Should I create new user and run these cmds?What difference this gonna make? In such case, what privileges should I set while creating the new user.

Okay, sorry I assumed you'd be on a PC. As such there shouldn't be any problem. Can you join in on discord so as to solve this prob faster? (see readme for link)

Sure.

So the issue has now boiled down to improper opencv installation, causing the import cv2 line to fail:
Here are related discussions to help you solve it:
https://stackoverflow.com/questions/49540507/opencv-segmentation-fault-core-dumped
opencv/opencv#9568

On a clean droplet, some of these libraries get missing. Following Adrian's blog, you should install the following explicitly now(after pip install is done).

sudo apt-get install -y build-essential cmake unzip pkg-config
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libatlas-base-dev gfortran

@Siva2406 Is your issue solved now?

Yes. I am able to proceed now. Thanks for your support.