Пример #1
0
long CApnCamera::PostStopExposure( bool DigitizeData )
{
	PUSHORT			pRequestData;


	if ( !DigitizeData )
	{
		while ( !ImageReady() )
		{
			Sleep( 50 );
			read_ImagingStatus();
		}

		pRequestData = new USHORT[m_pvtWidth*m_pvtHeight];

		ApnUsbGetImage( pRequestData );

		delete [] pRequestData;

		SignalImagingDone();
	}

	// The following code will eventually be the implementation of the STOP
	// command for USB.  Currently, this does not work correctly.
	// if ( ApnUsbStopExp( DigitizeData ) != APN_USB_SUCCESS )
	// {
	//	return 1;
	// }

	return 0;
}
Пример #2
0
void SpotifyImages::FetchImagesForArtist(int id, const QString& spotify_id) {
  QUrl artist_url(QString(kSpotifyArtistUrl).arg(spotify_id));
  qLog(Debug) << "Fetching images for artist:" << artist_url;
  QNetworkRequest request(artist_url);
  QNetworkReply* reply = network_->get(request);
  NewClosure(reply, SIGNAL(finished()), [this, id, reply]() {
    reply->deleteLater();
    QJson::Parser parser;
    QVariantMap result = parser.parse(reply).toMap();
    QVariantList images = result["images"].toList();
    QList<QPair<QUrl, QSize>> image_candidates;
    for (QVariant i : images) {
      QVariantMap image = i.toMap();
      int height = image["height"].toInt();
      int width = image["width"].toInt();
      QUrl url = image["url"].toUrl();
      image_candidates.append(qMakePair(url, QSize(width, height)));
    }
    if (!image_candidates.isEmpty()) {
      QPair<QUrl, QSize> winner =
          *std::max_element(
              image_candidates.begin(), image_candidates.end(),
              [](const QPair<QUrl, QSize>& a, const QPair<QUrl, QSize>& b) {
                return (a.second.height() * a.second.width()) <
                       (b.second.height() * b.second.width());
              });
      emit ImageReady(id, winner.first);
    }
    emit Finished(id);
  });
}
Пример #3
0
void KSaneWidgetPrivate::ImageData(TW_MEMREF pdata, TW_IMAGEINFO& info)
{
    if (pdata && (info.ImageWidth != -1) && (info.ImageLength != - 1))
    {
        // Under Windows, Twain interface return a DIB data structure.
        // See http://en.wikipedia.org/wiki/Device-independent_bitmap#DIBs_in_memory for details.
        HGLOBAL hDIB     = (HGLOBAL)(qptrdiff)pdata;
        int size         = (int)GlobalSize(hDIB);
        const char* bits = (const char*)GlobalLock(hDIB);

        // DIB is BMP without header. we will add it to load data in QImage using std loader from Qt.
        QByteArray baBmp;
        QDataStream ds(&baBmp, QIODevice::WriteOnly);

        ds.writeRawData("BM", 2);

        qint32 filesize = size + 14;
        ds << filesize;

        qint16 reserved = 0;
        ds << reserved;
        ds << reserved;

        qint32 pixOffset = 14 + 40 + 0;
        ds << pixOffset;

        ds.writeRawData(bits, size);

        emit ImageReady(baBmp, 0,0,0, (int)KSaneWidget::FormatBMP);

        GlobalUnlock(hDIB);

    }
}
Пример #4
0
// -----------------------------------------------------------------------------
// CCamcTest_5::ImageBufferReady
// MCameraObserver2 call-back handler
// -----------------------------------------------------------------------------
//
void CCamcTest_5::ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError)
    {
    PRINT(( _L( "CCamcTest_5::ImageBufferReady() BUFFER NOT HANDLED, err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() ));
	
    if ( !aError )
        {
	    aCameraBuffer.Release();
        }
    ImageReady( NULL, NULL, aError );
    }
Пример #5
0
bool CApnCamera::GetImageData( unsigned short *pImageBuffer, 
								   unsigned short &Width,
								   unsigned short &Height,
								   unsigned long  &Count )
{
        unsigned short	Offset(0);
	unsigned short	*pTempBuffer;
	long			i, j;


	// Make sure it is okay to get the image data
	// The app *should* have done this on its own, but we have to make sure
	while ( !ImageReady() )
	{
		Sleep( 50 );
		read_ImagingStatus();
	}

	Width	= m_pvtWidth;
	Height	= m_pvtHeight;

	if ( m_pvtBitsPerPixel == 16 )
		Offset = 1;

	if ( m_pvtBitsPerPixel == 12 )
		Offset = 10;

	Width -= Offset;	// Calculate the true image width

	pTempBuffer = new unsigned short[(Width+Offset) * Height];
	
	ApnUsbGetImage( pTempBuffer );

	for ( i=0; i<Height; i++ )
	{
		for ( j=0; j<Width; j++ )
		{
			pImageBuffer[(i*Width)+j] = pTempBuffer[(i*(Width+Offset))+j+Offset];
		}
	}

	delete [] pTempBuffer;
 

	Count = read_ImageCount();

	SignalImagingDone();

	return true;
}
Пример #6
0
void ArtistBiography::FetchWikipediaImages(int id, const QString& wikipedia_url,
                                           CountdownLatch* latch) {
  latch->Wait();
  qLog(Debug) << wikipedia_url;
  QRegExp regex("([a-z]+)\\.wikipedia\\.org/wiki/(.*)");
  if (regex.indexIn(wikipedia_url) == -1) {
    emit Finished(id);
    return;
  }
  QString wiki_title = QUrl::fromPercentEncoding(regex.cap(2).toUtf8());
  QString language = regex.cap(1);
  QUrl url(QString(kWikipediaImageListUrl).arg(language));
  url.addQueryItem("titles", wiki_title);

  qLog(Debug) << "Wikipedia images:" << url;

  QNetworkRequest request(url);
  QNetworkReply* reply = network_->get(request);
  NewClosure(reply, SIGNAL(finished()), [this, id, reply, language, latch]() {
    reply->deleteLater();

    QJson::Parser parser;
    QVariantMap response = parser.parse(reply).toMap();

    QStringList image_titles = ExtractImageTitles(response);

    for (const QString& image_title : image_titles) {
      latch->Wait();
      QUrl url(QString(kWikipediaImageInfoUrl).arg(language));
      url.addQueryItem("titles", image_title);
      qLog(Debug) << "Image info:" << url;

      QNetworkRequest request(url);
      QNetworkReply* reply = network_->get(request);
      NewClosure(reply, SIGNAL(finished()), [this, id, reply, latch]() {
        reply->deleteLater();
        QJson::Parser parser;
        QVariantMap json = parser.parse(reply).toMap();
        QUrl url = ExtractImageUrl(json);
        qLog(Debug) << "Found wikipedia image url:" << url;
        if (!url.isEmpty()) {
          emit ImageReady(id, url);
        }
        latch->CountDown();
      });
    }

    latch->CountDown();
  });
}
Пример #7
0
void ThreadToProcessImages::run()
{
    //qDebug() << "From Thread inside Run: " << QThread::currentThread();
    while(1){

        mCameraManager->waitNewImage(mCameraManager->getVideoFlag());

        if(mCameraManager->getProcessImageFlag()){
            mCameraManager->processLastImageAcquired(1);
        }

        if(mCameraManager->getSendImageFlag()){
            emit(ImageReady(mCameraManager->pixMapRGB888));
        }

        if(abortAcquisition){
            return;
        }
    }

}
Пример #8
0
void ThreadToProcessImages::ProcessImage(int sel)
{
    mCameraManager->processLastImageAcquired(sel);
    emit(ImageReady(mCameraManager->pixMapRGB888));

}
Пример #9
0
void ThreadToProcessImages::CamManagerGetSingleShotImage()
{
    mCameraManager->singleShotImage();
    emit(ImageReady(mCameraManager->pixMapRGB888));
}