This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to capture an image??

Hi,

           We are working with DM355_IPNC camera  which using montavista linux 2.6.10,arm_v5t_le. Actually we want to create a C-program for capturing the picture.Can anyone tell me that how to do this??

We have tried with the following program but it was not working..plz can anyone help me??

code

include "ApproDrvMsg.h"

#include "Appro_interface.h"

#include "cmem.h"

#include "Msg_Def.h"

#include <stdio.h>

int i;



void Init_Interface(int Msg_id)

{

    int qid;

    if(ApproDrvInit(Msg_id))

    exit(1);



    if(func_get_mem(&qid))

    {

    ApproDrvExit();

    exit(1);

    }

}



int SaveAudioFile( char *pFileName )

{

        FILE *pfd = NULL;

        int error_code = 0;

        int     SerialBook = -1;

        int     SerialLock = -1;

        int     ret = 0;

        int     save_cnt = 1;

        AV_DATA av_data;

        

        pfd = fopen(pFileName,"wb");

        if( pfd == NULL )

        {

               // ERR("open file error!!");

                error_code = -1;

                goto RECORD_QUIT;

        }





        if( fseek( pfd, 0, SEEK_SET ) < 0)

        {

               // ERR("seek file error!!");

                error_code = -1;

                goto RECORD_QUIT;

        }

        

        do

        {

                GetAVData(AV_OP_GET_MJPEG_SERIAL, -1, &av_data );

        } while (av_data.serial < 0);

        

        SerialBook = av_data.serial;

        

        while( save_cnt > 0)

        {

                ret = GetAVData(AV_OP_LOCK_MJPEG, SerialBook, &av_data );

                if (ret == RET_SUCCESS)

                {

                        if( fwrite( av_data.ptr,av_data.size,1, pfd )  <= 0)

                        {

                               // ERR("save file error!!");

                                error_code = -1;

                                goto RECORD_QUIT;

                        }

                        if (SerialLock >= 0)

                        {

                                GetAVData(AV_OP_UNLOCK_MJPEG, SerialLock, &av_data);

                        }

                        SerialLock = SerialBook;

                        save_cnt--;

                        SerialBook++;

                }

                else

                {

                        GetAVData(AV_OP_GET_MJPEG_SERIAL, -1, &av_data );                               

                        if( SerialBook > av_data.serial )

                        {

                                // delay for waiting next frame

                               // usleep(5);

                                 // sleep();

                for(i=0;i<1000;i++);



                        }else{

                                SerialBook = av_data.serial;

                        }

                }

        }

        GetAVData(AV_OP_UNLOCK_MJPEG, SerialLock, &av_data);

RECORD_QUIT:

        if( pfd )

        {

                fclose(pfd);

        }

        return error_code;

}



int main()

{

    int result = 0;

    char *pFileName = "snap_test.jpg";

    Init_Interface(0x01);

    result = SaveAudioFile(pFileName );

    

    return 0;

}

 

Makefile

# Makefile
#

# Set this to where Rules.make exists
ROOTDIR = ../../..
TARGET = take_snap


include $(ROOTDIR)/Rules.make

#CONFIG = codec/codecscfg

C_FLAGS += -Wall -g

#$(shell cat $(CONFIG)/compiler.opt)

CPP_FLAGS += -I$(DVEVM_INSTALL_DIR)/demos/utils/include \
                -I$(LINUXKERNEL_INSTALL_DIR)/include \
                -I./appro_3a \
        -D_GNU_SOURCE \
        -D_LARGEFILE64_SOURCE \
        -D_FILE_OFFSET_BITS=64 \
                $(XDC_FLAGS)

LD_FLAGS += -lfreetype -lpng -ljpeg -lpthread

all:
    $(MVTOOL_PREFIX)gcc $(LD_FLAGS) take_snap.o -o take_snap $(LIB_DIR)/cmem.a $(LIB_DIR)/Appro_interface.a

        #$(MVTOOL_PREFIX)gcc $(C_FLAGS) $(CPP_FLAGS) -c take_snap.c
    #$(MAKE) take_snap.c

#
#COMPILE.c = $(MVTOOL_PREFIX)gcc $(C_FLAGS) $(CPP_FLAGS) -c
#LINK.c = $(MVTOOL_PREFIX)gcc $(LD_FLAGS)
#
#RELTARGET = $(TARGET)
#
#RELCFLAGS = -O2 -fno-strict-aliasing
#
#SOURCES = $(wildcard *.c)
#HEADERS = $(wildcard *.h)
#
#RELOBJFILES = $(SOURCES:%.c=release/%.o)
#
#RELLDFLAGS =
#
#release:    codec_chk    $(RELTARGET)
#codec_chk:
#    $(MAKE)  -C take_snap
#

#
#
#.PHONY: clean release install
#
#all:    release
#
#install: release
#    install -d $(EXEC_DIR)
#    install $(RELTARGET) $(EXEC_DIR)
#
#release:    codec_chk    $(RELTARGET)
#
#codec_chk:
#    $(MAKE) -C codec/
#
#codec/dm355_mpeg4_enc.o:
#    $(MAKE) -C codec/
#
#$(RELTARGET):   $(RELOBJFILES) codec/dm355_enc.o appro_3a/Appro_3A.a
#    $(LINK.c) -o $@ $^ $(RELLDFLAGS)
## $(CONFIG)/linker.cmd
#
#
#$(RELOBJFILES): release/%.o: %.c $(HEADERS)
#    @mkdir -p release
#    $(COMPILE.c) $(RELCFLAGS) -o $@ $<
#
#clean::
#    -$(RM) -rf release  *.d
#    $(MAKE) -C codec/ clean
#