DSP

DM8148 摄像头采集 显示 识别测试 一

2019-07-13 14:40发布

和dm3730相比,a8端的识别,确实速度快一点,但目的还是想用dm8148的dsp端,下一步把dsp的识别加速放进来。dm8148 做汽车电子 的车载平台,是相当有优势的。做智能仪表 全景泊车 行人识别等,都可以用它。   主程序:   /* * * * zoushiwen,GXUT,广西工学院 ,qq406460538 * * * * */ /* * * */ extern "C" { #include #include #include #include #include #include #include #include #include #include #include #include #include #include } #include "opencv/highgui.h" #include "opencv/cv.h" #include "opencv/cxcore.h" #include "opencv/cvaux.h" #include "video_cap.h" #include "displayFb.h" #include "objdetect.h" int main( int argc, char** argv ) { //声明IplImage指针 IplImage* pImg = NULL; IplImage* pCannyImg = NULL; IplImage* pGRAYImg = NULL; IplImage* imageColor = NULL; int width = 640; int height = 480; VideoDevice * m_pVideoDev = new VideoDevice(width,height); CDisplayFB * m_pDisplay = new CDisplayFB; CObjdetect * m_pObjdetect = new CObjdetect; /*****************************open capture*************************************/ int rs; int index; unsigned char *pp; unsigned char * p; unsigned int len; pp = (unsigned char *)malloc(width * height* 2 * sizeof(char)); rs = m_pVideoDev->openCamera("/dev/video0"); if (rs < 0) { printf("Error in opening camera device "); return rs; } /*****************************open capture end ********************************/ /* Open the Display driver. */ int ret; ret = m_pDisplay->initFB("/dev/fb0",width, height); if (ret < 0) { printf("Error in opening display device for channel 0 "); return ret; } /*open display end */ imageColor = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); // initial the objdetect m_pObjdetect->Initdetect("haarcascade_frontalface_alt.xml"); for(;;) { index = m_pVideoDev->get_frame((void **)&p,&len); m_pVideoDev->YUVToRGB24_N((unsigned char *)p,(unsigned char *) imageColor->imageData, width, height); //m_pObjdetect->detect_and_draw(imageColor, 2.3, 1.5,2.0 ); m_pDisplay->copyImageToFB((unsigned char *) imageColor->imageData,width, height); rs = m_pVideoDev->unget_frame(); // usleep(300000); } end: rs = m_pVideoDev->stop_capturing(); rs = m_pVideoDev->uninit_device(); rs = m_pVideoDev->close_device(); cvReleaseImage( &imageColor ); free(pp); m_pDisplay->exitFB(); delete [] m_pVideoDev; delete [] m_pDisplay; delete [] m_pObjdetect; return -1; }   makefile 如下 #LIB = -L/usr/lib/mysql -lmysqlclient -L./ -lcfg #INCLUDE = -I/usr/include/mysql #LIB = -L/home/omap/omap3530/dvsdk/dvsdk_3_00_02_44/linuxlibs/lib -ljpeg #INCLUDE = -I/home/omap/omap3530/dvsdk/dvsdk_3_00_02_44/linuxlibs/include #LIB = -L/home/omap/lib -ljpeg #INCLUDE = -I/home/omap/work/opencv/build/include # ROOTDIR = . KERNEL_DIR =/opt/DM8148/ezsdk/board-support/linux-2.6.37-psp04.04.00.01 #This is root directory where Source is available. Change this path #to the one where source files are kept INSTALL_DIR = ./ #this is the path to the executable where all the executables are kept EXE_DIR = ./bin #This is path to the Include files of Library #LIB_INC = $(INSTALL_DIR)/User_Library #This is the path the include folder of the kernel directory. The include #folder should contain all the necessary header files INCLUDE_DIR = $(KERNEL_DIR)/include -I$(KERNEL_DIR)/arch/arm/include/ -I$(KERNEL_DIR)/arch/arm/plat-omap/include/ #This is the prefix applied to the gcc when compiling applications and library COMPILER_PREFIX = arm-none-linux-gnueabi CROSS_COMPILE = $(COMPILER_PREFIX)- #This is the toolchain base folder #TOOLCHAIN_DIR = /opt/codesourcery/2009q1-203 TOOLCHAIN_DIR = /opt/DM8148/arm-2009q1 #add cflags CPPFLAGS += -march=armv7-a -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp CPPFLAGS += -I$(TOOLCHAIN_DIR)/$(COMPILER_PREFIX)/libc/usr/include -I$(KERNEL_DIR) #Libc path LDFLAGS="-isystem $(TOOLCHAIN_DIR)/$(COMPILER_PREFIX)/libc/lib" #This is the path to the Directory containing Library LIB_DIR = $(TOOLCHAIN_DIR)/$(COMPILER_PREFIX)/libc/lib CFLAGS = -g -Os -march=armv7-a -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -I$(INCLUDE_DIR) -pipe -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -D__EXPORTED_HEADERS__ #LDFLAGS = -L/opt/codesourcery/arm-none-linux-gnueabi/libc/lib LDFLAGS = -L/opt/DM8148/arm-2009q1/arm-none-linux-gnueabi/libc/lib LIBS := -lpthread # # Platform specific options # CFLAGS += -DCONFIG_TI81XX #$(CROSS_COMPILE)gcc $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $(addsuffix .c,${@F}) #CC =/opt/DM8148/arm-2009q1/bin/arm-none-linux-gnueabi-gcc OPENCV2_2_INCLUDE_FILE=/opt/DM8148/opencv/opencv8148/include/ OPENCV2_2_LIB_FILE=/opt/DM8148/opencv/opencv8148/lib INCLUDE=-I$(OPENCV2_2_INCLUDE_FILE) LIB+=-L$(OPENCV2_2_LIB_FILE) -lopencv_core -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_imgproc CPPFLAG=-Wall -O2 -g -I$(OPENCV2_2_INCLUDE_FILE) TARGET = exe SRC = $(wildcard *.cpp *.o) OBJ = $(patsubst %.cpp, %.o, $(SRC)) %.o : %.c, %.h $(CROSS_COMPILE)gcc -c $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) $< -o $@ %.o : %.cpp $(CROSS_COMPILE)gcc -c $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) $< -o $@ $(TARGET) : $(OBJ) $(CROSS_COMPILE)gcc $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) $^ -o $@ $(INCLUDE) $(LIB) .PHONY: clean clean: $(RM) $(TARGET) $(OBJ)