Image-CCV
view release on metacpan or search on metacpan
ccv-src/doc/http.md view on Meta::CPAN
How can I use it?
-----------------
Following chapters assumed that you have basic understanding of curl.
The HTTP API as it is now, only supports 5 major ccv functionalities: BBF, DPM, SWT, TLD and
SIFT. All these APIs are discoverable, you can simply:
curl localhost:3350
and it will return you the list of API endpoints that you can navigate, try one:
curl localhost:3350/dpm/detect.objects
It returns:
{
"request":{
"interval":"integer",
"min_neighbors":"integer",
"model":"string",
ccv-src/doc/http.md view on Meta::CPAN
A more advanced example would be TLD.
Under the hood?
---------------
On Life-cycle of a Request
Whenever you issued a HTTP request, ccv received such request with libev, in asynchronous fashion,
and then dispatch a processing function to another thread with libdispatch, when the data is
ready, ccv will dispatch back to main event loop and send result back. Thus, requests to ccv
won't block each other. Although silly, dummy GET requests to ccv HTTP API endpoints can easily
peak to around 25K requests per second, you shouldn't worry too much about its HTTP performance
(you should more worry about its computer vision algorithms' performance).
On Error Message
ccv's HTTP endpoints doesn't provide informative error messages, if you issued a request that
it cannot handle, will return 400 with 'false' in its body. It may not be a problem for most
of the API endpoints, but it would be for some advanced ones.
On Parameters
All HTTP API's parameters can be easily interpreted through the C API documentation, ccv chooses
reasonable defaults from start, so any of them are optional.
On Security
The HTTP API endpoints are not intended to be exposed to public Internet, you should hide these
behind firewalls.
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
FileChunk *pChunk; /* Specific chunk into which cursor points */
};
/*
** This subclass is a subclass of sqlite3_file. Each open memory-journal
** is an instance of this class.
*/
struct MemJournal {
sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */
FileChunk *pFirst; /* Head of in-memory chunk-list */
FilePoint endpoint; /* Pointer to the end of the file */
FilePoint readpoint; /* Pointer to the end of the last xRead() */
};
/*
** Read data from the in-memory journal file. This is the implementation
** of the sqlite3_vfs.xRead method.
*/
static int memjrnlRead(
sqlite3_file *pJfd, /* The journal file from which to read */
void *zBuf, /* Put the results here */
int iAmt, /* Number of bytes to read */
sqlite_int64 iOfst /* Begin reading at this offset */
){
MemJournal *p = (MemJournal *)pJfd;
u8 *zOut = zBuf;
int nRead = iAmt;
int iChunkOffset;
FileChunk *pChunk;
/* SQLite never tries to read past the end of a rollback journal file */
assert( iOfst+iAmt<=p->endpoint.iOffset );
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
sqlite3_int64 iOff = 0;
for(pChunk=p->pFirst;
ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
pChunk=pChunk->pNext
){
iOff += JOURNAL_CHUNKSIZE;
}
}else{
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
int iAmt, /* Number of bytes to write */
sqlite_int64 iOfst /* Begin writing at this offset into the file */
){
MemJournal *p = (MemJournal *)pJfd;
int nWrite = iAmt;
u8 *zWrite = (u8 *)zBuf;
/* An in-memory journal file should only ever be appended to. Random
** access writes are not required by sqlite.
*/
assert( iOfst==p->endpoint.iOffset );
UNUSED_PARAMETER(iOfst);
while( nWrite>0 ){
FileChunk *pChunk = p->endpoint.pChunk;
int iChunkOffset = (int)(p->endpoint.iOffset%JOURNAL_CHUNKSIZE);
int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset);
if( iChunkOffset==0 ){
/* New chunk is required to extend the file. */
FileChunk *pNew = sqlite3_malloc(sizeof(FileChunk));
if( !pNew ){
return SQLITE_IOERR_NOMEM;
}
pNew->pNext = 0;
if( pChunk ){
assert( p->pFirst );
pChunk->pNext = pNew;
}else{
assert( !p->pFirst );
p->pFirst = pNew;
}
p->endpoint.pChunk = pNew;
}
memcpy(&p->endpoint.pChunk->zChunk[iChunkOffset], zWrite, iSpace);
zWrite += iSpace;
nWrite -= iSpace;
p->endpoint.iOffset += iSpace;
}
return SQLITE_OK;
}
/*
** Truncate the file.
*/
static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
MemJournal *p = (MemJournal *)pJfd;
ccv-src/lib/3rdparty/sqlite3/sqlite3.c view on Meta::CPAN
static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){
UNUSED_PARAMETER2(NotUsed, NotUsed2);
return SQLITE_OK;
}
/*
** Query the size of the file in bytes.
*/
static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
MemJournal *p = (MemJournal *)pJfd;
*pSize = (sqlite_int64) p->endpoint.iOffset;
return SQLITE_OK;
}
/*
** Table of methods for MemJournal sqlite3_file object.
*/
static const struct sqlite3_io_methods MemJournalMethods = {
1, /* iVersion */
memjrnlClose, /* xClose */
memjrnlRead, /* xRead */
( run in 0.743 second using v1.01-cache-2.11-cpan-524268b4103 )