Opencv 3.2 Install Dependencies Error

Mani,

You are right, I missed that.
Per your instruction given at Github and forum, I set swap space of 8GB and set 52GB Linux file workspace in 64GB SD Card (Scan Disk Ultra) and I ran it again. (and of course I corrected opencv_contrib path)
Using “make -j 2” it freezes on 29%.
so I used “make” per your advice and it freezes on 100%, darn it!
last message is this and it stuck there for over 2 hours and I had to restart.
“[100%] Building CXX object modules/python2/CmakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o”
Any thought?

Thank you,
Martin Kim

@Martin_Kim, OpenCV build freezes is not an unusual issue TBH.

I would say please make sure that you can detect the swap memory by issuing the swapon command and build it again using make.

If problem persists, please try to set the zram swap memory as specified in the below guide:

https://github.com/96boards/documentation/blob/master/ConsumerEdition/guides/zram_swapspace.md

Thanks,
Mani

Mani,

I re-install eMMC (fresh from start once again) and this time, added 16 GB swap-space on SD card and typed $ df -hT command, strangely it only shows 8 GB only on mmcblk1p1 (swapfile PT). and also created Swap space using ZRAM per your instruction.

To make sure, I ran Swapon command and it shows both of swap space and ran build again.

This time I was able to compile and build opencv into 410c.

Thank you very much!
Martin

Mani,
I ran “sudo python facetrack.py” and entered name, camera turned on streaming video of my face and servo moved few second and showed bounding box on my face then it stopped moving and no bounding box and I got many lines of this error msg until I hit “q”
"Corrupt JPEG data: 4 extraneous bytes before marker 0xd1
Corrupt JPEG data: 1 extraneous bytes before marker 0xd5
Corrupt JPEG data: 2 extraneous bytes before marker 0xd1
Corrupt JPEG data: 1 extraneous bytes before marker 0xd5
Corrupt JPEG data: 1 extraneous bytes before marker 0xd2
Corrupt JPEG data: 1 extraneous bytes before marker 0xd1
Corrupt JPEG data: 1 extraneous bytes before marker 0xd2
Corrupt JPEG data: 2 extraneous bytes before marker 0xd3
Corrupt JPEG data: 1 extraneous bytes before marker 0xd1
linaro@linaro-alip:~/projects/home_surveillance/part-3$ "

Dataset was prepared along with names, and bounding box showed name when it was shown.

Update: for this post above, I bought and used Logitech c270 USB Cam, which I thought was what you used for your build, based on picture from your post (my guess) and I wanted to use a USB-Cam to duplicate your build as similar as I can.

Since there were errors, I wanted to try with another USB Cam to see if the result is any different and I went bought a Logitech c920 again, which I had problems with Pi3 & Opencv build in the past and end up returned it because of this Cam had Video Codec compression built into hardware that somehow didn’t work with Pi3 & Opencv build (Remember I’m totally newbie in both HW & Software).

At my surprise, this Cam didn’t generate same “Corrupt----)” msg, and the tilt(Y axe) servo moved upward progressively and stopped at end point (I think I need to reverse servo rotation somehow) and it appear tilt function is working on my build but not the X axe(Pan function is not moving).

I’ll tinker with servo connections (it’s all on piggy board with loose wiring and taped servo mounting for now (c920 is much heavier than c270 and micro-size servo is burning out fast and I already burned two and I’m using larger servo with external power supply --not the 5 Volt from mezzanine board pin to protect both 410c & mezzanine here on).

What I noticed so far is that facial recognition rate is about 30 to 40 % accuracy to recognize my face from single data source (Only my faces are in data-set and only one my face is presented in USB Cam)–bounding box displays “unknown” and “my name” alternatively per distance and position of my face changes even in short distance of 3 to 5 feet.
My biggest question to you today is that is it feasible to implement 3rd servo to zoom in & out of subject face to optimize recognition using 96 board hardware and your code edit to implement such function?

I understand it will take much more computing power and alternative servo movement control (much faster) and optical focus.

Would you share your thought please and I’ll appreciate any input from this forum as well.

Thank you Mani and lJking
Martin

ljking,

Thank you very much for your input, I was able to build Opencv in 410c with your input and Mani’s suggestion of using ZRAM.
I’m a totally newbie in Arduino, Linux, Unix, Python, Opencv and 96 boards.

I’d like to try most recent version of Python3 build method of yours matching newer version of Stretch for Opencv build.

Most of project that I found on internet (Face Tracking & Object Tracking of Pan & Tilt) were based on pre Python2.7 based and I couldn’t duplicate any of them yet as a none programming or program experienced of any kind as a beginner. not able to modify 2.7 to 3 or modify Opencv changes in codes And not many response from this poster were provided to me despite many request and follow-up from my side in the past.

I guess it’s because of most of these post or instruction were published by individual and based on their particular OS, Version, Dependency and Program Environment that followers like me can not duplicate the exact same or modify to make it work and end up abandoning it at some point without making successful project like I’ve been through.

I’m hoping there will be a central point of downloading and setup point will be presented at 96 boards to attract beginner like me that such source is not depend on any other variable in the future version changes to experience a new hardware and software combination for positive experiences and better information navigational link to understand how to proceed with their new order arrival.

Thank you and Mani
Martin

Hi @Martin_Kim,

You can ignore the Corrupt JPEG data: warning now. But I’m not sure why Servo stopped tracking. Are you sure that there isn’t any error message displayed in console? If not please look for any loose connections to servo!

Regarding the detection accuracy, this project has been created to give the users starting point to Face detection on 96Boards, so it won’t be that accurate. But in order to make it efficient, you can increase the number of samples while capturing the dataset.

Also, the accuracy depends on lot of factors like ambient light, dataset of all angles etc… For more information on improving the accuracy please take a look at the Appendix section of final blog:

Regarding the use of servo zoom: You don’t need to do that inorder to improve accuracy, but I would recommend using one of our Camera Mezzanines like D3 camera mezzanine [1]. Since it includes features like Autofocus it will be more efficient in recognition.

Hope this helps!

Thanks,
Mani

[1] D3 DesignCore™ Camera Mezzanine Board on OpenHours - 96Boards

Mani,

I think I found the problem with servo.
I don’t know how I was able to upload to Mezzaine at the first time, after I modify servo direction of X by changing + -, I click upload and it generate this msg and I tried with your original .ino file and same msg.

This is that error msg "facetrack.ino:1:1: error: ‘sudo’ does not name a type
In file included from facetrack.ino:5:0:
/home/linaro/sketchbook/libraries/Servo/Servo.h:83:41: error: ‘timer16_Sequence_t’ does not name a type
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;

                                     ^"

I tried this on my macbook and no error and I’m scratching my head here, since I don’t know how-else to upload to Mezzaine.

Thank you again and help is appreciated.
Martin

@Martin_Kim,

Please paste your facetrack.ino file in pastebin and give me the link. I will take a look.

Mani,

I just pasted my facetrack.ino file into your pastebin.

Prior to do that I tried to compile facetrack.ino on Linaro in multiple different ways until I succeed.

And the way was to open Arduino from open programming GUI, select Arduino, open new file, copy and paste from your Github and use save-as diffirent name, then rename it to facetrack.ino in sketckbook folder and upload to Mezzanine.

What is strange upon successful compile and upload of facetrack.ino is that Y servo always move to endpoint with hissing noise (maximum servo position noise) upon “sudo python facetrack.py” command that is way beyond of 90 degree default .ino file setting in regardless of X & y + or - setting changes in .ino file.

And my face, is of course beyond recognition range and code terminates with opencv error msg “nameprint”, unless I’m holding Cam to focus my face within few second.

Could it be Opencv or Arduino issue? and how can I fix this?

Thank you.
Martin

Mani,

Sorry to bother you once again.

It appear servo behavior is nothing to do with servo rotation direction or change of +, - of X or Y direction to Update the position variable in facetrack.ino file, rather it may have something to do with Opencv processing, Python, facetrack.ino, Mezzanine or 410c board.

Things I did to come-up with this guess is that;
1: I used your original facetrack.ino file and servos are connected directly to Mezzanine as it shown on your Github diagram at this time.
2: When Mezzanine is plugged onto 410c and powered up, it hung or freezes on first power up on cold boot (When power source is unplugged more than 10 minutes)
couple of stuck on boot messages as example are follow;
“[ 15.615669] Bluetooth: hico command timeout 0x1003 tx timeout”
“[ 6.19973]x3: ffffffff00000000 x12 0000000000000038”
and upon unplug and re powering, it is able to boot into GUI on second time in most of boot cases.
3: Bluetooth from GUI application is not connecting but it shows bluetooth device and address, and even shows pairing number screen output for bluetooth keyboard yet does not connect to keyboard or mouse despite they are shown with address with connect prompt that I clicked on.
4: I tried with multiple diffirent servos to duplicate outcome to figure out HW or SW issues as follow; Futaba S148(Analog Servo)-- Upon "Sudo Python facetrack.py followed by name input, it goes all the way back or forward depend on +,- changes and shows Opencv error “name print----”, unless I hold Cam to focus on my face within couple of second, and then Cam progressively goes into end point and stuck on endpoint regardless of +,- changes on X (tilt) axe on facetrack.ino, it stuck on all the way on forward or backward depend on +,- changes. (my face shown with bounding box until it disappear out of screen and servo stop.
Hitech5485HB (Digital Servo)-- Same result, and I changed servo rotation direction (I bought Hitech digital servo for this test purpose) and the result was same with analog servo above.
5: I tried with external power supply to drive servo to see it any changes, yet result are same as above 3 & 4 for both kind.
6: USB Cam is mounted same way as your setup; mounted on Y axe mounted over X axe.

Update 11/12
I tried with different Webcam (one that I had problem with Dataset —Logitech c270).
Working!!! but it continueoly circle around screen area and my face all over on left corner as it seems to recognize that’s the center of screen area. And it’s movement is too fast that video stream is all too jerky.

I set screen size to 640*480 in facetrack.ino and it circle around center position this time (still all over around fast).

I set “int incx = 1; and int inc = 1;” but this doesn’t change speed, and still circle around too fast same.
It also generate same msg stream “Corrupt JPEG data: 1 extraneous bytes before marker 0xd1” continuously.

Thinking that msg may cause of “circle around fast” problem, I installed v41-utils and plugged c920 back and restart, hoping that will fix.

It boots up on first try now and no more “Corrupt —” msg, but it still circle around all over fast behavior.

On both cam, upon “sudo python facetrack.py and name entry” servo always swing back about 45 degree fast and come right back to position very fast and it misses face and terminate itself back to prompt in most of time.

1: How do I maintain default servo position upon command? so it doesn’t quit processing.
2: How do I slow down servo position change speed? for stabilized video stream and processing.
3: Do I need to rebuild Opencv because of v41utils installation?
4: Can this project can be duplicated in Hikey960 same way per your project instruction? if so, will it make difference in terms of accuracy (recognition process)?

Bluetooth is still not working and I haven’t done cold boot on Mezzanine.

Thank you very much and help is appreciated.

Martin,

Hi @Martin_Kim,

I’m not really sure of the Bluetooth issue you are currently facing. Maybe @Loic can provide some insight.

Regarding the OpenCV/Servo issue, it looks like there are some incompatibilities with the webcam you are using. Please try changing the screen size below in facetrack.ino to suit your need.

#define  ServoX_Max   180   // Maximum X axis tilt (degrees)
#define  ServoY_Max   180   // Maximum Y axis pan (degrees)
#define  ScreenX_Max   320  // Maximum X axis screen resolution
#define  ScreenY_Max   240  // Maximum Y axis screen resolution
#define  ServoX_Pos   90    // Default X axis position of servo (degrees)
#define  ServoY_Pos   120   // Default Y axis position of servo (degrees)

Before getting proper debian build for Hikey960, it is hard to recreate this project on it. Also, this project may not work on Hikey6220 also as it got some USB issue.

Thanks,
Mani

Think it should be better to open topics for different issues you meet if not linked together.

Don’t worry about this msg, this is a known issue, sometimes, the first Bluetooth HCI packet is not acked by the controller, however this is handled by the Bluetooth core which performs retries. Moreover this is not related to the mezzanine.

I’m going to check that.

@Mani @ljking @danielt @anon91830841
I have dragon board 410c newly purchased. And I have flashed it with debian based linux in emmc.
My problem is I wanted to install Opencv. During my search over net I came to this thread. And followed all the steps.

But I am still not able to install opencv. (opencv3.2)
At first compilation It was throwing error for liblapack and on second run for java error.
Now I have disabled in cmake (java and libapack =off)
But still the compilation gets freeze on 19% and after long waiting it throws error.

EDIT 1:- I have disabled the libs that was throwing errors, But Still I am not able to compile opencv. The error now is, I am running out of space ( after creating swapfile also, I have tried swap files of 1G to 1.5G as mentioned, But still errors. ).

Is there anyway that I can compile on SD CARD and then install on board?

Could please help me out here.

Thanks in advance.

@hector_ice Error: running out of space is due to lack of onboard eMMC storage space. Please delete some files and make room for OpenCV to be compiled.

Regarding other errors (java, libapack) please share the error log if you are interested in fixing without disabling the modules.

Thanks,
Mani

Hi Mani,

Thank you for the Replay., I will post the error logs for sure.
But For disk space is considered. I have not copied nor installed anything other then
relevant updates & upgrade for OpenCV.

I aim for installing opencv. At first after flashing the image, (I am using debian sd card installer image) I get some around 3.5 G free space. After installing necessary packages and doing Update & upgrade and also download , I left with 1.4 GB( without creating swap area yet).

How do I manage here, ?
Any suggestions would be very helpful to achieve this in deadline.
Otherwise, If not much to ask, If you have installed opencv to your board in debian.
would you be able to share the image So that I can compare what I am missing here.

Thanks

Hi @hector_ice,

I don’t have the image to share with you. But I would suggest you to move OpenCV source to SD card and build it from there. By this way you can save the eMMC space for installation.

Also please move the Swapfile too to SD card. For building OpenCV you need more RAM (atleast for multithreading), so consider using SD swapspace or ZRAM.

Thanks,
Mani

Hi Mani,

I have tried to build opencv on memory card but failed on 46% saying
write error " No permission provided" to write in opencv files.

I may be doing wrong. Could you tell me steps or link from where I can build the opencv
on sd card.

Also One quick question:- If i boot from SD card ( using the image to boot from sd card) and do a build on the sd card and for future also I boot from sd card only. would that work?

Would that be advisable?

Thanks

Ahh… You are booting from SD card! Any special reason for that? Why can’t you use eMMC?

Noo,
I have posted the question for eMMC , But I was also going through the forums ,
And got idea to go with sd card booting method,. Just to build opencv

No other special reasons.
I have deadline to match for program and opencv is not at all getting installed.

Thats why as workaround I thought to try.

Okay. But I would suggest you to boot from eMMC and clone the source onto SD card and build it from there. For doing the build, please make sure you have formatted the SD card in ext4 format and the user has R/W/X permissions.

Please remove the old source and do a fresh build.

Thanks,
Mani