I made up a new Directory and placed Face detect code (Toradex Sample code)
and Run the whole sequence now with Following output.
abc@ubuntu:~$ cd /usr/local/oecore-x86_64
abc@ubuntu:/usr/local/oecore-x86_64$ ls
environment-setup-armv7at2hf-vfp-angstrom-linux-gnueabi
site-config-armv7at2hf-vfp-angstrom-linux-gnueabi
sysroots
version-armv7at2hf-vfp-angstrom-linux-gnueabi
abc@ubuntu:/usr/local/oecore-x86_64$ . environment-setup-armv7at2hf-vfp-angstrom-linux-gnueabi
abc@ubuntu:/usr/local/oecore-x86_64$ make
make: *** No targets specified and no makefile found. Stop.
abc@ubuntu:/usr/local/oecore-x86_64$ clear
abc@ubuntu:/usr/local/oecore-x86_64$ . environment-setup-armv7at2hf-vfp-angstrom-linux-gnueabi
abc@ubuntu:/usr/local/oecore-x86_64$ cd
abc@ubuntu:~$ mkdir new1 && cd new1
abc@ubuntu:~/new1$ nano new_prog1.cpp
abc@ubuntu:~/new1$ nano Makefile
abc@ubuntu:~/new1$ nano Makefile
abc@ubuntu:~/new1$ make
Makefile:14: *** missing separator. Stop.
abc@ubuntu:~/new1$ nano Makefile
abc@ubuntu:~/new1$ make
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++ -O2 -g -Wall -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include -L/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/lib -lpthread -lopencv_highgui -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect -lm new_prog1.cpp -o new_prog1
In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core/cvdef.h:91:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core.hpp:52,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/objdetect.hpp:47,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/objdetect/objdetect.hpp:48,
from new_prog1.cpp:1:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core/hal/interface.h:15:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
Makefile:11: recipe for target 'new_prog1' failed
make: *** [new_prog1] Error 1
Code:-
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include "stdio.h"
using namespace std;
using namespace cv;
CascadeClassifier face_cascade;
string window_name = "Face Detection Demo";
String face_cascade_name = "/home/root/haarcascade_frontalface_alt2.xml";
const int BORDER = 8; /* order between GUI elements to the edge of the image */
template <typename T> string toString(T t)
{
ostringstream out;
out << t;
return out.str();
}
/*
* Draw text into an image. Defaults to top-left-justified text,
* but you can give negative x coords for right-justified text,
* and/or negative y coords for bottom-justified text
* Returns the bounding rect around the drawn text
*/
Rect drawString(Mat img, string text, Point coord, Scalar color,
float fontScale = 0.6f, int thickness = 1, int fontFace = FONT_HERSHEY_COMPLEX)
{
/* Get the text size & baseline */
int baseline = 0;
Size textSize = getTextSize(text, fontFace, fontScale, thickness, &baseline);
baseline += thickness;
/* Adjust the coords for left/right-justified or top/bottom-justified */
if (coord.y >= 0) {
/*
* Coordinates are for the top-left corner of the text
* from the top-left of the image, so move down by one row.
*/
coord.y += textSize.height;
} else {
/*
* Coordinates are for the bottom-left corner of the text
* from the bottom-left of the image, so come up from the bottom
*/
coord.y += img.rows - baseline + 1;
}
/* Become right-justified if desired */
if (coord.x < 0) {
coord.x += img.cols - textSize.width + 1;
}
/* Get the bounding box around the text */
Rect boundingRect = Rect(coord.x, coord.y - textSize.height, textSize.width, baseline + textSize.height);
/* Draw anti-aliased text */
putText(img, text, coord, fontFace, fontScale, color, thickness, CV_AA);
/* Let the user know how big their text is, in case they want to arrange things */
return boundingRect;
}
int main(int argc, const char** argv)
{
VideoCapture capture;
Mat frame;
std::vector<Rect> faces;
Mat frame_gray;
if (!face_cascade.load( face_cascade_name ) ) {
printf("--(!)Error loading training file: haarcascade_frontalface_alt2.xml\n");
return -1;
};
try {
capture.open("v4l2:///dev/video3");
capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
}
catch (cv::Exception &e)
{
const char *err_msg = e.what();
cout << "Exception caught: " << err_msg << endl;
}
if ( !capture.isOpened() ) {
cout << "ERROR: Could not access the camera!" << endl;
exit(1);
}
while(true) {
capture >> frame;
if (!frame.empty()) {
cvtColor(frame, frame_gray, CV_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
face_cascade.detectMultiScale(frame_gray, faces, 1.2, 3, CV_HAAR_DO_CANNY_PRUNING, Size(80, 80));
for (size_t i = 0; i < faces.size(); i++) {
CvPoint pt1 = { faces[i].x, faces[i].y };
CvPoint pt2 = { faces[i].x + faces[i].width, faces[i].y + faces[i].height };
rectangle(frame, pt1, pt2, CV_RGB(0, 255, 0), 3, 4, 0);
Mat faceROI = frame_gray(faces[i]);
}
string stringToDisplay = "Number Of Faces: " + toString(faces.size());
drawString(frame, stringToDisplay, Point(BORDER, -BORDER - 2 - 50), CV_RGB(0, 0, 0));
drawString(frame, stringToDisplay, Point(BORDER + 1, -BORDER - 1 - 50), CV_RGB(0, 255, 0));
imshow(window_name, frame);
} else {
printf(" --(!) No captured frame");
}
int c = waitKey(1);
if ((char)c == 27) {
break;
}
}
return 0;
}
MakeFile-
SYSROOTS ?= /usr/local/oecore-x86_64/sysroots
CC = ${SYSROOTS}/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++
INCLUDES = -I${SYSROOTS}/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include
LIB_PATH = -L${SYSROOTS}/armv7at2hf-vfp-angstrom-linux-gnueabi/lib
LIBS = -lpthread -lopencv_highgui -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect -lm
CFLAGS = -O2 -g -Wall -mfloat-abi=hard --sysroot=${SYSROOTS}/armv7at2hf-vfp-neon-angstrom-linux-gnueabi
all: new_prog1
new_prog1: new_prog1.cpp
${CC} ${CFLAGS} ${INCLUDES} ${LIB_PATH} ${LIBS} new_prog1.cpp -o new_prog1
clean:
rm -rf new_prog1
.PHONY : all clean
Errors-
bc@ubuntu:~/new1$ make
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++ -O2 -g -Wall -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include -L/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/lib -lpthread -lopencv_highgui -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect -lm new_prog1.cpp -o new_prog1
In file included from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core/cvdef.h:91:0,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core.hpp:52,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/objdetect.hpp:47,
from /usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/objdetect/objdetect.hpp:48,
from new_prog1.cpp:1:
/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-angstrom-linux-gnueabi/usr/include/opencv2/core/hal/interface.h:15:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
Makefile:11: recipe for target 'new_prog1' failed
make: *** [new_prog1] Error 1