fastest write speed

I am developing an application with a camera that captures at 41fps 2.3MP, I analyse the images with opencv and write the regions of interest to disk. Sometimes I get “brusts” of detection so I would like to be able to write images to disk at the fastest speed. In my tests, when I use my code to write all images to disk I am only reaching 2fps.
Any recommendation of the fastest write media to use?

Hi gelu,

How do you write images to disk? What’s the method you used?
What kind of disk you are using now? On what interface?

Please provide more information, and then we can have the proper suggestion.

Besides, Jetson TK1 can have the SD card and SDIO interfaces support up to UHS-I, thought some cards might got error, and need further investigation, you could refer to other thread to see if any helps:

Thanks

Sorry for my late reply.
I am using opencv to write the images to disk, using cv::imwrite, bellow is the cpp code I use. The camera is a point grey blackfly USB3 and I am using the Flycapture API and converting to openCV Mat format.
So far I’ve tried writing to the Jetson internal memory and to a Class10 SD Card. With this code I get average 3.9fps on the internal memory.
Would a UHS-I result in an increase of speed?
Many thanks.

//=============================================================================
// Copyright © 2008 Point Grey Research, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of Point
// Grey Research, Inc. ("Confidential Information").  You shall not
// disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with PGR.
//
// PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================
//=============================================================================
// $Id: FlyCapture2Test.cpp,v 1.19 2010-03-11 22:58:37 soowei Exp $
//=============================================================================

#include "stdafx.h"
#include <iostream>
#include <sstream>
#include "FlyCapture2.h"


#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

#include <iostream>

using namespace FlyCapture2;
using namespace std;


#include <ctime>


void printtime(clock_t begin, std::string texto)
{
  clock_t end=clock();
  double timeSec = (end - begin) / static_cast<double>( CLOCKS_PER_SEC );
  std::cout << "Time elapsed "<<texto<<" : " << timeSec << std::endl;
} 

void printfps(clock_t begin, int NFrames, std::string texto)
{
  clock_t end=clock();
  double timeSec = (end - begin) / static_cast<double>( CLOCKS_PER_SEC );
  std::cout << "Frames per second "<< texto <<" : " << NFrames/timeSec << std::endl;
  //  std::cout << "Frames: "<<NFrames<<" Time elapsed "<<texto<<" : " << timeSec << std::endl;
} 



void PrintBuildInfo()
{
    FC2Version fc2Version;
    Utilities::GetLibraryVersion( &fc2Version );
    
	ostringstream version;
	version << "FlyCapture2 library version: " << fc2Version.major << "." << fc2Version.minor << "." << fc2Version.type << "." << fc2Version.build;
	cout << version.str() << endl;  
    
	ostringstream timeStamp;
    timeStamp <<"Application build date: " << __DATE__ << " " << __TIME__;
	cout << timeStamp.str() << endl << endl;  
}

void PrintCameraInfo( CameraInfo* pCamInfo )
{
    cout << endl;
	cout << "*** CAMERA INFORMATION ***" << endl;
	cout << "Serial number -" << pCamInfo->serialNumber << endl;
    cout << "Camera model - " << pCamInfo->modelName << endl;
    cout << "Camera vendor - " << pCamInfo->vendorName << endl;
    cout << "Sensor - " << pCamInfo->sensorInfo << endl;
    cout << "Resolution - " << pCamInfo->sensorResolution << endl;
    cout << "Firmware version - " << pCamInfo->firmwareVersion << endl;
    cout << "Firmware build time - " << pCamInfo->firmwareBuildTime << endl << endl;
	
}

void PrintError( Error error )
{
    error.PrintErrorTrace();
}

int RunSingleCamera( PGRGuid guid )
{

	std::vector<std::vector<cv::Point> > contours;
	std::vector<cv::Vec4i> hierarchy;
	int blurwindow=55; // blur kernel size
	int threshlimit=55; // threshold limit
	bool savesteps=true;



	clock_t begin, end;
	double timeSec;
	begin = clock();

	cv::Mat orig_image,dst_host,grey,blurred,thresh;

	// Stream and string to generate filenames
	std::stringstream ss;
	std::string filename;

    Error error;
    Camera cam;

    // Connect to a camera
    error = cam.Connect(&guid);
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    // Get the camera information
    CameraInfo camInfo;
    error = cam.GetCameraInfo(&camInfo);
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    PrintCameraInfo(&camInfo);        

    // Start capturing images
    error = cam.StartCapture();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    char key = 0;
    begin = clock();
    int NumFramesCounter=0;
    Image rawImage;
    Image rgbImage;
    //    cv::Mat image;
    unsigned int rowBytes;

    vector<int> compression_parms;
    compression_parms.push_back(CV_IMWRITE_PNG_COMPRESSION);
    compression_parms.push_back(1);
    
    while(key != 'q')
      {
	//for ( int imageCnt=0; imageCnt < k_numImages; imageCnt++ )
	//    {                

        // Retrieve an image
        error = cam.RetrieveBuffer( &rawImage );
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            continue;
        }


	  rawImage.Convert( FlyCapture2::PIXEL_FORMAT_BGR, &rgbImage );
	  
	  //	  convert to OpenCV Mat
	  rowBytes = (double)rgbImage.GetReceivedDataSize()/(double)rgbImage.GetRows();       
	  orig_image = cv::Mat(rgbImage.GetRows(), rgbImage.GetCols(), CV_8UC3, rgbImage.GetData(),rowBytes);

	  // // some openCV operations
	  // cv::cvtColor(orig_image,grey,CV_BGR2GRAY);
	  // cv::blur(grey,blurred,cv::Size(blurwindow,blurwindow));
	  // cv::threshold(blurred, thresh, threshlimit, 255.0, CV_THRESH_BINARY_INV);
	  // cv::findContours(thresh,contours,hierarchy,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE);


	    ss<< "New" << NumFramesCounter << ".png";
	    filename = ss.str().c_str();	
	    ss.str(std::string()); // Clears the stringstream content
	    cv::imwrite(filename,orig_image);
		
	  // cv::imshow("image CV", image);
	  // key = cv::waitKey(30);        

	// if(NumFramesCounter % 10 == 0) {
	//   printfps(begin,NumFramesCounter,"");
	// }
	NumFramesCounter++;
	printfps(begin,NumFramesCounter,"");
        

    }            

    // Stop capturing images
    error = cam.StopCapture();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }      

    // Disconnect the camera
    error = cam.Disconnect();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    return 0;
}

int main(int /*argc*/, char** /*argv*/)
{    
    PrintBuildInfo();

    Error error;

    // Since this application saves images in the current folder
    // we must ensure that we have permission to write to this folder.
    // If we do not have permission, fail right away.
	FILE* tempFile = fopen("test.txt", "w+");
	if (tempFile == NULL)
	{
		cout << "Failed to create file in current folder.  Please check permissions." << endl; 
		return -1;
	}
	fclose(tempFile);
	remove("test.txt");

    BusManager busMgr;
    unsigned int numCameras;
    error = busMgr.GetNumOfCameras(&numCameras);
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    cout << "Number of cameras detected: " << numCameras << endl; 

    for (unsigned int i=0; i < numCameras; i++)
    {
        PGRGuid guid;
        error = busMgr.GetCameraFromIndex(i, &guid);
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        }

        RunSingleCamera( guid );
    }

    cout << "Done! Press Enter to exit..." << endl; 
    cin.ignore();

    return 0;
}

Hi gelu74,

Would a UHS-I result in an increase of speed?
Yes, in theoretically, UHS-I results in an increase of speed than Class10 SD card, but should still be slower than internal memory/eMMC.

It seems the storage device is not the key point of slow performance.

Thanks

Hi gelu74,

I am trying to set up flycapture sdk to run on Jetson TK1. I am using Nsight Eclispe edition on the host (Ubuntu 14.04) and I have installed flycapture.2.9.3.43_arm64 on the target and flycapture2-2.9.3.43-amd64 on the host. When I try to build the project, I keep getting the this error “/usr/lib/libflycapture.so: file not recognized: File format not recognized”

15:08:36 **** Build of configuration Release for project proj1 ****
make all -C /home/ubuntu/Cuda-sproj/proj1/Release
make: Entering directory `/home/ubuntu/Cuda-sproj/proj1/Release’
Building file: …/code1.cu
Invoking: NVCC Compiler
/usr/local/cuda-6.5/bin/nvcc -I/usr/include/flycapture -O3 -ccbin arm-linux-gnueabihf-g++ -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -odir “” -M -o “code1.d” “…/code1.cu”
/usr/local/cuda-6.5/bin/nvcc -I/usr/include/flycapture -O3 --compile --relocatable-device-code=true -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -ccbin arm-linux-gnueabihf-g++ -x cu -o “code1.o” “…/code1.cu”
Finished building: …/code1.cu

Building target: proj1
Invoking: NVCC Linker
/usr/local/cuda-6.5/bin/nvcc --cudart shared -L/usr/lib -L/usr/arm-linux-gnueabihf/lib -ccbin /usr/bin --relocatable-device-code=true -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -link -o “proj1” ./code1.o /usr/lib/libopencv_core.so -lflycapture -lcuda
/usr/lib/libflycapture.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [proj1] Error 1
make: Leaving directory `/home/ubuntu/Cuda-sproj/proj1/Release’

Shell Completed (exit code = 2)

I will appreciate if you can give me an advice on how to do the cross compilation for flycapture.
Thanks