Exemplo n.º 1
0
void DocbookDocVisitor::visitPost(DocImage *img)
{
    if (img->type()==DocImage::Latex)
    {
        if (m_hide) return;
        QCString typevar;
        m_t << "</title>" << endl;
        m_t << "    <mediaobject>" << endl;
        m_t << "        <imageobject>" << endl;
        QCString baseName=img->name();
        int i;
        if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
        {
            baseName=baseName.right(baseName.length()-i-1);
        }
        m_t << "            <imagedata";
        if (!img->width().isEmpty())
        {
            m_t << " width=\"";
            filter(img->width());
            m_t << "\"";
        }
        else if (!img->height().isEmpty())
        {
            m_t << " depth=\"";
            filter(img->height());
            m_t << "\"";
        }
        m_t << " align=\"center\" fileref=\"" << baseName << "\">";
        m_t << "</imagedata>" << endl;
        m_t << "        </imageobject>" << endl;
        m_t << "    </mediaobject>" << endl;
        m_t << "    </figure>" << endl;
        // copy the image to the output dir
        QCString m_file;
        bool ambig;
        FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
        if (fd)
        {
            m_file=fd->absFilePath();
        }
        QFile inImage(m_file);
        QFile outImage(Config_getString("DOCBOOK_OUTPUT")+"/"+baseName.data());
        if (inImage.open(IO_ReadOnly))
        {
            if (outImage.open(IO_WriteOnly))
            {
                char *buffer = new char[inImage.size()];
                inImage.readBlock(buffer,inImage.size());
                outImage.writeBlock(buffer,inImage.size());
                outImage.flush();
                delete[] buffer;
            }
        }
    }
    else
    {
        popEnabled();
    }
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    Q_UNUSED(a)

    QImage inImage("lena.png");
    inImage = inImage.convertToFormat(QImage::Format_Grayscale8);
    QImage outImage(inImage.size(), inImage.format());

    QVector<int> gradient;
    QVector<int> direction;
    sobel(inImage, gradient, direction);
    QVector<int> thinned = thinning(inImage.width(), inImage.height(),
                                   gradient, direction);
    QVector<int> thresholded = threshold(75, 150, thinned);
    QVector<int> canny = hysteresis(inImage.width(), inImage.height(),
                                    thresholded);

    const int *iImg = canny.constData();
    quint8 *oImg = outImage.bits();

    int size = inImage.width() * inImage.height();

    for (int i = 0; i < size; i++)
        oImg[i] = qBound(0, iImg[i], 255);

    outImage.save("canny.png");

    return EXIT_SUCCESS;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: jrubill/2100
int main( int argc, char *argv[])
{
   scene_t *scene;
   FILE    *inFP;

   /* Open scene definition file */
   if (argc != 3) {
      fprintf(stderr, "Usage: ./ray mdl_file ppm_image_file\n");
      exit(1);
   }
   if ((inFP = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "ERROR: could not open sdl file \"%s\"\n", argv[1]);
      exit(1);
   }

   /* Load and dump scene data */
   scene = createScene(inFP);

   dumpScene(stderr, scene);

   /* Render the image */
   render(scene);

   /* And output the image to a PPM file */
   outImage(argv[2], scene->picture);

   return 0;
}
Exemplo n.º 4
0
void processImageFiles()
{
	QString workingImageDirPath = QString(workingAssetsDir) + "Textures\\";
	QDir workingImageDir (workingImageDirPath);
	if(workingImageDir.exists())
	{
		QStringList imageFileFilters;
		imageFileFilters << "*.png";

		workingImageDir.setFilter(QDir::Files | QDir::NoSymLinks);
		workingImageDir.setNameFilters(imageFileFilters);
		QFileInfoList workingImageFiles = workingImageDir.entryInfoList();

		for(int i = 0; i < workingImageFiles.size(); i++)
		{
			QFileInfo unprocessedImageFile = workingImageFiles.at(i);
			QFileInfo outImage(QString(outAssetsDir) + "Textures\\" + unprocessedImageFile.fileName());

			bool needsCopy = (!outImage.exists() || (outImage.lastModified() < unprocessedImageFile.lastModified()));
			if(needsCopy)
			{
				QDir::root().mkpath(outImage.absolutePath());
				QImage workingImage = QImage(QDir::toNativeSeparators(unprocessedImageFile.absoluteFilePath()));
				workingImage = QGLWidget::convertToGLFormat(workingImage);
				bool saved = workingImage.save(outImage.absoluteFilePath(), "PNG");
			}
		}
	}
	else
	{
		qDebug("No working Image folder.");
	}
}
Exemplo n.º 5
0
void XmlDocVisitor::visitPre(DocImage *img)
{
  if (m_hide) return;

  QCString baseName=img->name();
  int i;
  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
  {
    baseName=baseName.right(baseName.length()-i-1);
  }
  visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, TRUE, img->type(), img->width(), img->height());

  // copy the image to the output dir
  FileDef *fd;
  bool ambig;
  if ((fd=findFileDef(Doxygen::imageNameDict,img->name(),ambig)))
  {
    QFile inImage(fd->absFilePath());
    QFile outImage(Config_getString(XML_OUTPUT)+"/"+baseName.data());
    if (inImage.open(IO_ReadOnly))
    {
      if (outImage.open(IO_WriteOnly))
      {
        char *buffer = new char[inImage.size()];
        inImage.readBlock(buffer,inImage.size());
        outImage.writeBlock(buffer,inImage.size());
        outImage.flush();
        delete[] buffer;
      }
    }
  }
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    Q_UNUSED(a)

    QImage inImage("lena.png");
    inImage = inImage.convertToFormat(QImage::Format_RGB32);
    QImage outImage(inImage.size(), inImage.format());

    // Here we configure the edge detector parameters.
    int radius = 1;
    qreal sigma = 1;
    qreal scaleXY = 1;
    qreal scaleW = 1;
    bool round = false;

    // Create gaussian denoise kernel.
    int kw;
    QVector<qreal> kernelX = edgeKernel(radius, sigma, scaleXY, scaleW, false, round, &kw);
    QVector<qreal> kernelY = edgeKernel(radius, sigma, scaleXY, scaleW, true, round, &kw);

    for (int y = 0; y < inImage.height(); y++) {
        const QRgb *iLine = (const QRgb *) inImage.constScanLine(y);
        QRgb *oLine = (QRgb *) outImage.scanLine(y);

        for (int x = 0; x < inImage.width(); x++) {
            qreal sumX = 0;
            qreal sumY = 0;

            // Apply kernel.
            for (int j = 0, pos = 0; j < kw; j++) {
                const QRgb *line = (const QRgb *) inImage.constScanLine(y + j - radius);

                if (y + j < radius
                    || y + j >= radius + inImage.height())
                    continue;

                for (int i = 0; i < kw; i++, pos++) {
                    if (x + i < radius
                        || x + i >= radius + inImage.width())
                        continue;

                    quint8 pixel = qGray(line[x + i - radius]);
                    sumX += kernelX[pos] * pixel;
                    sumY += kernelY[pos] * pixel;
                }
            }

            int grad = gradient(sumX, sumY, gradientType);
            quint8 c = qBound(0, grad, 255);
            oLine[x] = qRgba(c, c, c, qAlpha(iLine[x]));
        }
    }

    outImage.save("edge.png");

    return EXIT_SUCCESS;
}
Exemplo n.º 7
0
void saveFloatImageWeighted
(
    std::string savename,
    float *image,
    T *weight,
    int   width,
    int   height,
    int   channels,
    float minimum,
    float maximum
)
{
    cv::Mat outImage(cv::Size(width,height),CV_32FC4);
    if(channels==3) {
        for(int x=0; x<width*height; x++) {
            ((float*)(outImage.data))[4*x+0] = image[3*x+2];
            ((float*)(outImage.data))[4*x+1] = image[3*x+1];
            ((float*)(outImage.data))[4*x+2] = image[3*x+0];
            ((float*)(outImage.data))[4*x+3] = weight[x]==0 ? 0.0f : 255.0f;
        }
    }
    else if(channels==1) {
        for(int x=0; x<width*height; x++) {
            ((float*)(outImage.data))[4*x+0] = ((float*)(outImage.data))[4*x+1]= ((float*)(outImage.data))[4*x+2] = image[x];
            ((float*)(outImage.data))[4*x+3] = weight[x]==0 ? 0.0f : 255.0f;
        }
    }
    else {
        fprintf(stderr,"\nERROR: %i-Channel Weighted Debug Image not supported",channels);
    }

    if(maximum<minimum) {
        float avg = 0.0f;
        float newmax = -1e6f;
        float newmin = 1e6f;
        for(int x=0; x<width*height; x++) {
            for(int y=0; y<3; y++) {
                avg += ((float*)(outImage.data))[4*x+y];
                if(newmax < ((float*)(outImage.data))[4*x+y]) newmax = ((float*)(outImage.data))[4*x+y];
                if(newmin > ((float*)(outImage.data))[4*x+y]) newmin = ((float*)(outImage.data))[4*x+y];
            }
        }
        avg /= (float)(width*height*3);
        maximum = newmax;
        if(minimum > 0.0f) {
            minimum = newmin;
        }
        for(int x=0; x<width*height; x++) {
            for(int y=0; y<3; y++) {
                ((float*)(outImage.data))[4*x+y] = (((float*)(outImage.data))[4*x+y]-minimum)*(255.0f/(maximum-minimum));
            }
        }
        fprintf(stderr,"\nDebug Image %s Minimum: %f Maximum: %f Average: %f",savename.c_str(),minimum,maximum,avg);
    }

    cv::imwrite(savename.c_str(),outImage);
}
Exemplo n.º 8
0
int VibeUpdateForResult(JNIEnv* env,
                        const unsigned char* frameIn, 
                        jobject bitmap,
                        unsigned int wid, unsigned int hei ) {
    if ( detector_ == NULL) {
        detector_ = new bv::MD_ViBE(wid/SCALE, hei/SCALE);
    }
    if ( detector_ == NULL) {
        return -1;
    }

    bv::Image inImage(wid/SCALE + 1, hei/SCALE + 1);
    bv::Image outImage(wid/SCALE + 1, hei/SCALE + 1);
    
    inImage.data *= 0;
    for(int y = 0; y < (int)hei; y++) {
        for(int x = 0; x < (int)wid; x++) {
            int xx = x/SCALE;
            int yy = y/SCALE; 
            inImage.data(xx, yy) = frameIn[y*wid+x] + inImage.data(xx, yy);
        }
    }
    inImage.data /= SCALE*SCALE;

    int ret;
    ret = detector_->run(inImage, outImage);

    AndroidBitmapInfo  info; 
    unsigned int*              pixels;
    if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
        LOGD("AndroidBitmap_getInfo() failed ! error=%d", ret);
        return -1;
    }
    if ((ret = AndroidBitmap_lockPixels(env, bitmap, (void**)&pixels)) < 0) {
        LOGD("AndroidBitmap_lockPixels() failed ! error=%d", ret);
        return -1;
    }
   
    int lineStride = info.stride / 4;
    for(int y = 0; y < (int)hei; y++) {
        for(int x = 0; x < (int)wid; x++) {
            int xx = x/SCALE;
            int yy = y/SCALE; 
            if ( outImage.data(xx, yy) ) {
                pixels[y*lineStride+x] = 0xFFFFFFFF;
            } else {
                pixels[y*lineStride+x] = 0x00000000;
            }
        }
    }
 
    AndroidBitmap_unlockPixels(env, bitmap);
    return 0;
}
Exemplo n.º 9
0
void XmlDocVisitor::visitPre(DocImage *img)
{
    if (m_hide) return;
    m_t << "<image type=\"";
    switch(img->type())
    {
    case DocImage::Html:
        m_t << "html";
        break;
    case DocImage::Latex:
        m_t << "latex";
        break;
    case DocImage::Rtf:
        m_t << "rtf";
        break;
    }
    m_t << "\"";

    QCString baseName=img->name();
    int i;
    if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
    {
        baseName=baseName.right(baseName.length()-i-1);
    }
    m_t << " name=\"" << baseName << "\"";
    if (!img->width().isEmpty())
    {
        m_t << " width=\"";
        filter(img->width());
        m_t << "\"";
    }
    else if (!img->height().isEmpty())
    {
        m_t << " height=\"";
        filter(img->height());
        m_t << "\"";
    }
    m_t << ">";

    // copy the image to the output dir
    QFile inImage(img->name());
    QFile outImage(Config_getString("XML_OUTPUT")+"/"+baseName.data());
    if (inImage.open(IO_ReadOnly))
    {
        if (outImage.open(IO_WriteOnly))
        {
            char *buffer = new char[inImage.size()];
            inImage.readBlock(buffer,inImage.size());
            outImage.writeBlock(buffer,inImage.size());
            outImage.flush();
            delete[] buffer;
        }
    }
}
Exemplo n.º 10
0
Mat ImageCutter::extractROI(const Mat& inImage){
	Mat outImage(240, 640, inImage.type());

	for (tInt row = 240, rowOutImage = 0; row < 480 /*&& rowOutImage < 240*/; row++, rowOutImage++)
	{
		for (tInt col = 0; col < 640; col++)
		{
			outImage.at<Vec3b>(rowOutImage, col) = inImage.at<Vec3b>(row, col);
		}
	}

	return outImage;
}
Exemplo n.º 11
0
void DocbookDocVisitor::visitPost(DocImage *img)
{
  if (img->type()==DocImage::DocBook)
  {
    if (m_hide) return;
    visitPostEnd(m_t, img -> hasCaption());
    // copy the image to the output dir
    QCString baseName=img->name();
    int i;
    if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
    {
      baseName=baseName.right(baseName.length()-i-1);
    }
    QCString m_file;
    bool ambig;
    FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
    if (fd) 
    {
      m_file=fd->absFilePath();
    }
    QFile inImage(m_file);
    QFile outImage(Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data());
    if (inImage.open(IO_ReadOnly))
    {
      if (outImage.open(IO_WriteOnly))
      {
        char *buffer = new char[inImage.size()];
        inImage.readBlock(buffer,inImage.size());
        outImage.writeBlock(buffer,inImage.size());
        outImage.flush();
        delete[] buffer;
      }
    }
  } 
  else 
  {
    popEnabled();
  }
}
void BrowserUtils::generateIconFromFile(const QString inFile, const QString outFile, const QSize imageSize)
{
	QImage inImage(inFile);
	if (inImage.isNull()) {
		qWarning() << "generateIconFromFile - failed to open source file";
		Q_EMIT iconGenerated(false, outFile);
		return;
	}
	const int nMargin = 4;// Must agree with pixel data in image files
	const int nIconSize = 64;// Width & height of output image
	const int nIconWidth = nIconSize-2*nMargin;// Width of icon image within file
	const int nIconHeight = nIconSize-2*nMargin;
	QImage outImage(nIconSize, nIconSize, QImage::Format_ARGB32_Premultiplied);
	outImage.fill(0);
	QPainter painter(&outImage);
	painter.setRenderHint(QPainter::SmoothPixmapTransform);
	QRectF source(0.0, 0.0, imageSize.width(), imageSize.height());
	QRectF target(nMargin, nMargin, nIconWidth, nIconHeight);
	QRectF size(0.0, 0.0, nIconSize, nIconSize);
	painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
	painter.drawImage(target, inImage, source);
	painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
	QImage maskImage(kIconMaskFile);
	painter.drawImage(target, maskImage, target);
	painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
	QImage overlayImage(kIconOverlayFile);
	painter.drawImage(size, overlayImage, size);

	QFileInfo imageInfo(outFile);
	QDir imageDir(imageInfo.path());
	if (!imageDir.exists()) {
		imageDir.mkpath(".");
	}

	bool saved = outImage.save(outFile);
	Q_EMIT iconGenerated(saved, outFile);
}
Exemplo n.º 13
0
void VideoGeneration::on_generateVideoPushButton_clicked()
{
	//string camPath = "C:\\Users\\dehandecroos\\Desktop\\Videos\\PRG28.avi";
	QString profileId = ui.profileName_lineEdit->text();


	
	string cameraIds[] = { 
		"camera_node_6_log", 
		"camera_node_1_log", 
		"camera_node_28_log",
		"camera_node_23_log"
	};
	int cameraIdsSize = sizeof(cameraIds) / sizeof(*cameraIds);
	string finalJoinQuery = "";
	int i = 1;
	for (string cameraId : cameraIds)
	{
		finalJoinQuery += "select * from " + cameraId + " where profile_id='" + profileId.toStdString() + "'";
		if (i++ != cameraIdsSize) {
			finalJoinQuery += "union ";
		}
	}
	finalJoinQuery += "order by TimeStamp";
	
	struct CameraTimeStamp{
		string cameraId;
		double timestamp;
	};
	
	
	stmt->execute("USE camera");
	ResultSet *timeStampsForProfile = stmt->executeQuery(finalJoinQuery);
	vector<CameraTimeStamp> timeStamps;
	
	while (timeStampsForProfile->next())
	{
		CameraTimeStamp timeStamp;
		timeStamp.cameraId = timeStampsForProfile->getString("Video_ID");
		timeStamp.timestamp = timeStampsForProfile->getDouble("TimeStamp");
		timeStamps.push_back(timeStamp);
	}

	
	vector<Mat> video;
	for (CameraTimeStamp ts : timeStamps)
	{
		string camPath = "C:\\AdaptiveCameraNetworkPack\\Videos\\";
		string camId = ts.cameraId;
		camPath += "PRG" + camId + ".avi";
		VideoCapture cam;
		cam.open(camPath);
		int frameRate = cam.get(CV_CAP_PROP_FPS);

		int minutes = (int)ts.timestamp;
		int seconds = (int)((ts.timestamp-(double)minutes)*100.0);
		int milis = ((ts.timestamp - (double)minutes)*100.0-seconds)*1000;
		
		int milliseconds = (minutes * 60 + seconds) * 1000 + milis;
		qDebug() << "Extracted Frames for time " + QString::number(ts.timestamp) + ", in camera " + QString::fromStdString(camId);
		cam.set(CV_CAP_PROP_POS_MSEC, milliseconds);
		
		
		for (int frameCount = 0; frameCount < frameRate; frameCount++)
		{
			Mat frame;
			cam >> frame;
			if (frame.empty())
			{
				break;
			}
			int fontFace = FONT_HERSHEY_SIMPLEX;
			double fontScale = 1;
			int thickness = 3;
			cv::Point textOrg1(10, 50);
			putText(frame, "CAM:" + ts.cameraId, textOrg1, fontFace, fontScale, Scalar::all(0),2);
			cv::Point textOrg2(500, 50);
			video.push_back(frame);
		}
		
		

		//VideoCapture

	}

	if (video.size() == 0){
		QImage finalImage(ui.lblOutput->width(), ui.lblOutput->width(), QImage::Format_RGB888);
		QPainter qp(&finalImage);
		qp.setBrush(Qt::black);
		qp.setPen(Qt::red);
		qp.setFont(QFont("Times", 12, QFont::Bold));
		qp.drawText(finalImage.rect(), Qt::AlignCenter, "NO VIDEO FOR "+ profileId);
		ui.lblOutput->setPixmap(QPixmap::fromImage(finalImage));
	}
	else
	{
		for (Mat frameZ : video)
		{
			Mat frameForQimage;
			cvtColor(frameZ, frameForQimage, CV_BGR2RGB);
			QImage outImage((uchar*)frameForQimage.data, frameForQimage.cols, frameForQimage.rows, frameZ.step, QImage::Format_RGB888);
			ui.lblOutput->setPixmap(QPixmap::fromImage(outImage));
			imshow("Output", frameZ);
			cvWaitKey(1);

		}
	}
}