Exemple #1
0
/*!
 * \brief WindowManager::launchRegionWindow is called when the user has dragged a region across the screen.
 * This function launches the window allowing the user to see the region they have created,
 * and to specify options for that region (name, threshold, notes).  The user may only save a region IF that region has
 * a name.
 *
 * This function also displays an image of the current frame with the region the user selected drawn on it.
 * See the function saveFrameWhenRegionCreated for a description of that.
 *
 * \see RegionWindow.
 *
 * \param projName The project associated.
 * \param vidName The video we are adding a region to.
 * \param regionName The name of the region (if this is an edit/update).
 * \param x The x of the region (pixels)
 * \param y y of the region (pixels)
 * \param width width of the region (pixels)
 * \param height height of the region (pixels)
 */
void WindowManager::launchRegionWindow(QString projName, QString vidName, QString regionName, int videoTimeInMilliseconds, int newRegionNumber, int x, int y, int width, int height)
{
    ///////////Dustin Added: code that saves an image file calling functions i made, and returns its filepath as a string
    QString videoFilePath = getVideoPath(projName, vidName);

    //save an image to display when the user makes a region, and have openCV draw the region onto the image
    std::string tempPath = saveFrameWhenRegionCreated(videoFilePath, videoTimeInMilliseconds, x, y, width, height, newRegionNumber);

    QString imageFilePath = QString::fromStdString(tempPath);
    ///////////Dustin Added: code that saves an image file calling functions i made, and returns its filepath as a string

    int threshold = _bvSystem->getRegionThreshold(projName, vidName, regionName);
    QString notes = _bvSystem->getRegionNotes(projName, vidName, regionName);
    _regionWindow = new RegionWindow(0, this, projName, vidName, regionName, threshold, notes, x, y, width, height, imageFilePath);
    _regionWindow->setAttribute(Qt::WA_DeleteOnClose);
    _regionWindow->show();
}
VideoEditor::VideoEditor(NotesModule::Video* vid ,QWidget *parent) :QWidget(parent), ui(new Ui::VideoEditor), video(vid)
{
    ui->setupUi(this);
    ui->videoPlayer->setMinimumHeight(170);
    ui->volumeSlider->setAudioOutput(ui->videoPlayer->audioOutput());
    ui->volumeSlider->setEnabled(false);
    ui->pushButtonDelete->setEnabled(false);
    if (video){
        ui->lineEditTitle->setText(dynamic_cast<NotesModule::Note*>(video)->getTitle());
        ui->textEditDescription->setText(dynamic_cast<NotesModule::Multimedia*>(video)->getDescription());

    }

    QObject::connect(ui->pushButtonSave,SIGNAL(clicked()),this,SLOT(saveVideo()));
    QObject::connect(ui->lineEditTitle,SIGNAL(textEdited(QString)),this,SLOT(activateSave(QString)));
    QObject::connect(ui->textEditDescription,SIGNAL(textChanged()),this,SLOT(activateSave()));
    QObject::connect(ui->pushButtonBrowse,SIGNAL(clicked()),this,SLOT(getVideoPath()));
    QObject::connect(ui->pushButtonPlay,SIGNAL(clicked()),this,SLOT(playVideo()));
    QObject::connect(ui->pushButtonStop,SIGNAL(clicked()),this,SLOT(stopVideo()));
    QObject::connect(ui->pushButtonPause,SIGNAL(clicked()),this,SLOT(pauseVideo()));
    QObject::connect(ui->pushButtonDelete,SIGNAL(clicked()),this,SLOT(delete_note()));
}
// Load the movie
bool CSmpeg::Load( string fileName, SDL_Surface* renderEngineScreen, int maxscalex, int maxscaley )
{
	MaxScaleX = maxscalex;
	MaxScaleY = maxscaley;

	// Limit how much we can scale by
	MaxScale = (maxscalex > maxscaley ? maxscaley : maxscalex);

	// Assign the screen surface
	screen = renderEngineScreen;

	// Load the movie and store the information about it
	string filePath = getVideoPath(fileName);
	
	if(movie)
	{
		SMPEG_delete( movie );
		movie = 0;
	}
	if( filePath != "")
	{
		movie = SMPEG_new(filePath.c_str(), &movieInfo, true );
	}
	else
	{
		return false;
	}
	if(SMPEG_error(movie) != NULL)
	{
		log << WARN << "Load() - SMPEG_new() error: " << SMPEG_error(movie) << endl;
	}
	else
	{
		currentlyLoadedVideo = fileName;
	}
	

	// Create a temporary surface to render the movie to
	SDL_Surface* tempSurface2 = SDL_CreateRGBSurface( SDL_SWSURFACE, movieInfo.width * MaxScaleX, movieInfo.height * MaxScaleY, 32, screen->format->Rmask, 
														screen->format->Gmask, screen->format->Bmask, screen->format->Amask );

	// Now make a surface optimized for the main screen
	movieSurface = SDL_DisplayFormat( tempSurface2 );

	// Free the temporary surface
	SDL_FreeSurface( tempSurface2 );

	// Set the surface to draw to
	SMPEG_setdisplay( movie, movieSurface, 0, 0 );
	if(SMPEG_error(movie) != NULL)
	{
		log << WARN << "Load() - SMPEG_setdisplay() error: " << SMPEG_error(movie) << endl;
		return false;
	}
	

	// Set the display region
	SMPEG_setdisplayregion( movie, 0, 0, movieInfo.width, movieInfo.height );
	if(SMPEG_error(movie) != NULL)
	{
		log << WARN << "Load() - SMPEG_setdisplayregion() error: " << SMPEG_error(movie) << endl;
	}
	
	
	return true;
}