Changeset 98 in pacpussensors for trunk/Ladybug


Ignore:
Timestamp:
10/08/15 22:29:42 (9 years ago)
Author:
ndiasnak
Message:

Added: timestamp and DbiteFile to LadybugComponent

Location:
trunk/Ladybug
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ladybug/LadybugComponent.cpp

    r81 r98  
    3232// Construct the factory
    3333static ComponentFactory<LadybugComponent> sFactory("LadybugComponent");
     34static const size_t kMaxFilepathLength = 128;
    3435
    3536/* *Constructor*/
     
    5657        lbTotalNumberOfImagesWritten = 0;
    5758        lbNumOfFrames = 0;
     59
     60        if (lbSaveJPGImages)
     61        {
     62                try
     63                {
     64                        QString dbtFileName_ = "Camera_1.dbt";
     65                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     66                } catch (DbiteException & e) {
     67                        LOG_ERROR("error opening dbt file: " << e.what());
     68                }
     69
     70                try
     71                {
     72                        QString dbtFileName_ = "Camera_2.dbt";
     73                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     74                } catch (DbiteException & e) {
     75                        LOG_ERROR("error opening dbt file: " << e.what());
     76                }
     77
     78                try
     79                {
     80                        QString dbtFileName_ = "Camera_3.dbt";
     81                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     82                } catch (DbiteException & e) {
     83                        LOG_ERROR("error opening dbt file: " << e.what());
     84                }
     85
     86                try
     87                {
     88                        QString dbtFileName_ = "Camera_4.dbt";
     89                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     90                } catch (DbiteException & e) {
     91                        LOG_ERROR("error opening dbt file: " << e.what());
     92                }
     93
     94                try
     95                {
     96                        QString dbtFileName_ = "Camera_5.dbt";
     97                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     98                } catch (DbiteException & e) {
     99                        LOG_ERROR("error opening dbt file: " << e.what());
     100                }
     101
     102                try
     103                {
     104                        QString dbtFileName_ = "Camera_6.dbt";
     105                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     106                } catch (DbiteException & e) {
     107                        LOG_ERROR("error opening dbt file: " << e.what());
     108                }
     109    }
     110
     111        if (lbSavePanoImage)
     112        {
     113                try
     114                {
     115                        QString dbtFileName_ = "CameraPano.dbt";
     116                        mDbtImage1.open(dbtFileName_.toStdString(), WriteMode, FILE_DBT_UNKNOWN, kMaxFilepathLength);
     117                } catch (DbiteException & e) {
     118                        LOG_ERROR("error opening dbt file: " << e.what());
     119                }
     120    }
     121
    58122        THREAD_ALIVE = true;
    59123        start();
     
    66130        printf (" \n*** Stopping Activity ***\n");
    67131        LadybugError error;
     132
     133            // Close DBT files
     134    if (lbSaveJPGImages) {
     135                mDbtImage1.close();
     136                mDbtImage2.close();
     137                mDbtImage3.close();
     138                mDbtImage4.close();
     139                mDbtImage5.close();
     140                mDbtImage6.close();
     141    }
     142
     143        if (lbSavePanoImage) {
     144                mDbtImagePano.close();
     145        }
    68146
    69147        lbIsRecording = false;
     
    144222        CreateImageBuffers();
    145223
     224        // Timestamp
     225    road_time_t timestamp = 0;
     226    road_timerange_t tr = 0;
     227
    146228        while (THREAD_ALIVE)
    147229        {
     230
    148231                lbCurrentTime = GetTickCount(); // road_time_t timestamp = road_time(); // ui64 ; unit microsec ; Orig 01/01/1970 00:00
    149232                lbFrameCount++;
     
    158241
    159242                error = ladybugGrabImage( lbContext, &image );
    160                 // t = road_time(); // timestamp
     243                timestamp = road_time(); // timestamp
    161244                HandleError(error);
    162245
     
    245328        HandleError(error);
    246329
     330
     331        // Use it to trigger the camera with the gps signal
    247332        /*// Initialize Trigger
    248333        error = ladybugGetTriggerModeInfo( lbContext, &triggerModeInfo );
     
    356441                HandleError(error);
    357442
     443        if (uiCamera == 0)
     444                {
     445                        try {
     446                                mDbtImage1.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     447                        } catch (DbiteException & e) {
     448                                LOG_ERROR("error writing data: " << e.what());
     449                        }
     450                } else if (uiCamera == 1) {
     451                        try {
     452                                mDbtImage2.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     453                        } catch (DbiteException & e) {
     454                                LOG_ERROR("error writing data: " << e.what());
     455                        }
     456                }else if (uiCamera == 2) {
     457                        try {
     458                                mDbtImage3.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     459                        } catch (DbiteException & e) {
     460                                LOG_ERROR("error writing data: " << e.what());
     461                        }
     462                }else if (uiCamera == 3) {
     463                        try {
     464                                mDbtImage4.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     465                        } catch (DbiteException & e) {
     466                                LOG_ERROR("error writing data: " << e.what());
     467                        }
     468                }else if (uiCamera == 4) {
     469                        try {
     470                                mDbtImage5.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     471                        } catch (DbiteException & e) {
     472                                LOG_ERROR("error writing data: " << e.what());
     473                        }
     474                }else if (uiCamera == 5) {
     475                        try {
     476                                mDbtImage6.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     477                        } catch (DbiteException & e) {
     478                                LOG_ERROR("error writing data: " << e.what());
     479                        }
     480                }
     481
    358482                //printf("Saved camera %u image to %s.\n", uiCamera, pszOutputFilePath);
    359483
     
    401525        error = ladybugSaveImage(lbContext, &processedImage, pszOutputFilePath, LADYBUG_FILEFORMAT_JPG);
    402526        HandleError(error);
     527
     528        try {
     529                mDbtImagePano.writeRecord(time, tr, (char *) processedImage.pData, kMaxFilepathLength);
     530        } catch (DbiteException & e) {
     531                LOG_ERROR("error writing data: " << e.what());
     532        }
    403533
    404534}
  • trunk/Ladybug/LadybugComponent.h

    r81 r98  
    44//#include "Pacpus/kernel/pacpus.h"
    55#include "Pacpus/kernel/ComponentBase.h"
    6 //#include "Pacpus/kernel/DbiteFile.h"
     6#include "Pacpus/kernel/DbiteFile.h"
    77//#include "../NMEA0183/include/nmea0183.h"
    88
     
    121121                                int lbNumOfFrames;
    122122
     123                                DbiteFile mDbtImage1;
     124                                DbiteFile mDbtImage2;
     125                                DbiteFile mDbtImage3;
     126                                DbiteFile mDbtImage4;
     127                                DbiteFile mDbtImage5;
     128                                DbiteFile mDbtImage6;
     129                                DbiteFile mDbtImagePano;
     130
    123131        };
    124132}
Note: See TracChangeset for help on using the changeset viewer.