Visual Studio


#1

I have a VS C++ project that uses OpenCV, and i want to use Juce MIDI functionality on it. I haven't found any information that doesn't refers to creating brand new projects, i just want to add Juce to this one. So i've put both projects on the same solution, but when i try to use a class that references both projects, it doesn't compile because of all the ambiguous classes, like Point, and ambiguous macro types, like uint_64 and alike. What should i do to use Juce functionality at the OpenCV project?


#2

I've never actually tried generating MIDI, but I have created  an OpenCV VST plugin (which could generate MIDI O/p)

Mine limied captures to the same rate sample buffers were captured. It seemed to run fine

{I'll see if I can post-up some (old) project code }

Note, there's a Introjucer funny (or I've a misunderstanding!) so some of the code below needs modifying after saving by Introducer.

OpenCVST2.jucer

<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="Qw1y7m" name="OpenCVST2" projectType="audioplug" version="1.0.0"
              bundleIdentifier="com.midisticks.OpenCVST2" includeBinaryInAppConfig="1"
              buildVST="1" buildAU="1" pluginName="OpenCVST2" pluginDesc="OpenCVST2"
              pluginManufacturer="Midisticks Ltd" pluginManufacturerCode="Mstx"
              pluginCode="Plug" pluginChannelConfigs="{1, 1}, {2, 2}" pluginIsSynth="0"
              pluginWantsMidiIn="1" pluginProducesMidiOut="1" pluginSilenceInIsSilenceOut="0"
              pluginEditorRequiresKeys="0" pluginAUExportPrefix="OpenCVST2AU"
              pluginRTASCategory="" aaxIdentifier="com.midisticks.OpenCVST2"
              pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="3.1.0"
              companyName="Midisticks Ltd" buildVST3="1" buildRTAS="0" buildAAX="0"
              pluginManufacturerWebsite="www.yourcompany.com" pluginManufacturerEmail="support@yourcompany.com"
              companyWebsite="http://www.midisticks.com" companyEmail="info@midisticks.com">
  <MAINGROUP id="UCO43P" name="OpenCVST2">
    <GROUP id="{954D396C-83F3-D0DE-4A03-FA6E57B6F24A}" name="Source">
      <FILE id="CgcXCw" name="PluginProcessor.cpp" compile="1" resource="0"
            file="Source/PluginProcessor.cpp"/>
      <FILE id="ghpE1j" name="PluginProcessor.h" compile="0" resource="0"
            file="Source/PluginProcessor.h"/>
      <FILE id="aE1FE9" name="PluginEditor.cpp" compile="1" resource="0"
            file="Source/PluginEditor.cpp"/>
      <FILE id="TylPvx" name="PluginEditor.h" compile="0" resource="0" file="Source/PluginEditor.h"/>
    </GROUP>
  </MAINGROUP>
  <EXPORTFORMATS>
    <VS2013 targetFolder="Builds/VisualStudio2013" vstFolder="c:\SDKs\vstsdk2.4"
            vst3Folder="c:\SDKs\VST3 SDK" externalLibraries="$(OPENCV_DIR)\x86\vc11\lib\opencv_core247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_contrib247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_stitching247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_imgproc247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_ts247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_videostab247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_gpu247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_legacy247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_ml247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_nonfree247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_objdetect247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_calib3d247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_photo247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_video247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_features2d247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_highgui247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_flann247.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_core247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_contrib247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_stitching247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_imgproc247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_ts247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_videostab247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_gpu247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_legacy247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_ml247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_nonfree247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_objdetect247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_calib3d247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_photo247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_video247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_features2d247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_highgui247d.lib&#10;$(OPENCV_DIR)\x86\vc11\lib\opencv_flann247d.lib">
      <CONFIGURATIONS>
        <CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
                       isDebug="1" optimisation="1" targetName="OpenCVST213Db" headerPath="$(OPENCV_DIR)/include&#10;$(OPENCV_DIR)/include/opencv&#10;$(OPENCV_DIR)/include/opencv2"/>
        <CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
                       isDebug="0" optimisation="3" targetName="OpenCVST213" headerPath="$(OPENCV_DIR)/include&#10;$(OPENCV_DIR)/include/opencv&#10;$(OPENCV_DIR)/include/opencv2"/>
      </CONFIGURATIONS>
      <MODULEPATHS>
        <MODULEPATH id="juce_video" path="J:/modules"/>
        <MODULEPATH id="juce_opengl" path="J:/modules"/>
        <MODULEPATH id="juce_gui_extra" path="J:/modules"/>
        <MODULEPATH id="juce_gui_basics" path="J:/modules"/>
        <MODULEPATH id="juce_graphics" path="J:/modules"/>
        <MODULEPATH id="juce_events" path="J:/modules"/>
        <MODULEPATH id="juce_data_structures" path="J:/modules"/>
        <MODULEPATH id="juce_cryptography" path="J:/modules"/>
        <MODULEPATH id="juce_core" path="J:/modules"/>
        <MODULEPATH id="juce_audio_processors" path="J:/modules"/>
        <MODULEPATH id="juce_audio_plugin_client" path="J:/modules"/>
        <MODULEPATH id="juce_audio_formats" path="J:/modules"/>
        <MODULEPATH id="juce_audio_devices" path="J:/modules"/>
        <MODULEPATH id="juce_audio_basics" path="J:/modules"/>
      </MODULEPATHS>
    </VS2013>
  </EXPORTFORMATS>
  <MODULES>
    <MODULES id="juce_audio_basics" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_audio_devices" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_audio_formats" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_audio_plugin_client" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_audio_processors" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_core" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_cryptography" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_data_structures" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_events" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_graphics" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_gui_basics" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_gui_extra" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_opengl" showAllCode="1" useLocalCopy="1"/>
    <MODULES id="juce_video" showAllCode="1" useLocalCopy="1"/>
  </MODULES>
  <JUCEOPTIONS JUCE_QUICKTIME="disabled"/>
</JUCERPROJECT>

PluginEditor.cpp


/*

This is an automatically generated GUI class created by the Introjucer!

Be careful when adding custom code to these files, as only the code within
the “//[xyz]” and “//[/xyz]” sections will be retained when the file is loaded
and re-saved.

Created with Introjucer version: 3.1.0


The Introjucer is part of the JUCE library - "Jules’ Utility Class Extensions"
Copyright 2004-13 by Raw Material Software Ltd.

==============================================================================
*/

//[Headers] You can add your own extra header files here…
#include “PluginProcessor.h”
//[/Headers]

#include “PluginEditor.h”

//[MiscUserDefs] You can add your own user definitions and misc code here…
//#if JucePlugin_Name == #OpenCVSTNAME
//#undef JucePlugin_Name
//#define JucePlugin_Name
//#error “You haven’t re-defined JucePlugin_Name correctly”
//#endif
/*
Class should start
OpenCvst2AudioProcessorEditor::OpenCvst2AudioProcessorEditor (OpenCvst2AudioProcessor* ownerFilter)
: juce::AudioProcessorEditor(ownerFilter)
{
setName (“OpenCvst2AudioProcessorEditor”);
*/
//[/MiscUserDefs]

//==============================================================================
OpenCvst2AudioProcessorEditor::OpenCvst2AudioProcessorEditor (OpenCvst2AudioProcessor* ownerFilter)
: juce::AudioProcessorEditor(ownerFilter)
{
setName (“OpenCvst2AudioProcessorEditor”);
addAndMakeVisible (sliderA = new Slider (“slider1”));
sliderA->setTooltip (TRANS(“Slider1A”));
sliderA->setRange (-100, 100, 0);
sliderA->setSliderStyle (Slider::LinearVertical);
sliderA->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderA->addListener (this);

addAndMakeVisible (sliderB = new Slider ("slider2"));
sliderB-&gt;setTooltip (TRANS("Slider2B"));
sliderB-&gt;setRange (-100, 100, 0);
sliderB-&gt;setSliderStyle (Slider::LinearVertical);
sliderB-&gt;setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
sliderB-&gt;addListener (this);

//[UserPreSize]
//[/UserPreSize]

setSize (300, 300);

//[Constructor] You can add your own custom stuff here..
//[/Constructor]

}

OpenCvst2AudioProcessorEditor::~OpenCvst2AudioProcessorEditor()
{
//[Destructor_pre]. You can add your own custom destruction code here…
//[/Destructor_pre]

sliderA = nullptr;
sliderB = nullptr;

//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]

}

//==============================================================================
void OpenCvst2AudioProcessorEditor::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here…
//[/UserPrePaint]

g.fillAll (Colours::white);

//[UserPaint] Add your own custom painting code here..
//[/UserPaint]

}

void OpenCvst2AudioProcessorEditor::resized()
{
sliderA->setBounds (proportionOfWidth (0.0533f), proportionOfHeight (0.0533f), proportionOfWidth (0.2400f), proportionOfHeight (0.9067f));
sliderB->setBounds (proportionOfWidth (0.6933f), proportionOfHeight (0.0533f), proportionOfWidth (0.2400f), proportionOfHeight (0.9067f));
//[UserResized] Add your own custom resize handling here…
//[/UserResized]
}

void OpenCvst2AudioProcessorEditor::sliderValueChanged (Slider* sliderThatWasMoved)
{
//[UsersliderValueChanged_Pre]
//[/UsersliderValueChanged_Pre]

if (sliderThatWasMoved == sliderA)
{
    //[UserSliderCode_sliderA] -- add your slider handling code here..
    this-&gt;getAudioProcessor()-&gt;setParameter(0, (float)sliderThatWasMoved-&gt;getValue());
    //[/UserSliderCode_sliderA]
}
else if (sliderThatWasMoved == sliderB)
{
    //[UserSliderCode_sliderB] -- add your slider handling code here..
    this-&gt;getAudioProcessor()-&gt;setParameter(1, (float)sliderThatWasMoved-&gt;getValue());
    //[/UserSliderCode_sliderB]
}

//[UsersliderValueChanged_Post]
//[/UsersliderValueChanged_Post]

}

//[MiscUserCode] You can add your own definitions of your custom methods or any other code here…
//[/MiscUserCode]

//==============================================================================
#if 0
/* – Introjucer information section –

This is where the Introjucer stores the metadata that describe this GUI layout, so
make changes in here at your peril!

BEGIN_JUCER_METADATA

<JUCER_COMPONENT documentType=“Component” className="OpenCvst2AudioProcessorEditor"
componentName=“OpenCvst2AudioProcessorEditor” parentClasses=“public juce::AudioProcessorEditor"
constructorParams=“OpenCvst2AudioProcessor* ownerFilter” variableInitialisers=”"
snapPixels=“8” snapActive=“1” snapShown=“1” overlayOpacity=“0.330"
fixedSize=“1” initialWidth=“300” initialHeight=“300”>
<BACKGROUND backgroundColour=“ffffffff”/>
<SLIDER name=“slider1” id=“7f1ca3ecb680fa81” memberName=“sliderA” virtualName=”“
explicitFocusOrder=“0” pos=“5.333% 5.333% 24% 90.667%” tooltip=“Slider1A"
min=”-100” max=“100” int=“0” style=“LinearVertical” textBoxPos=“TextBoxBelow"
textBoxEditable=“1” textBoxWidth=“80” textBoxHeight=“20” skewFactor=“1”/>
<SLIDER name=“slider2” id=“83cab52b410faa82” memberName=“sliderB” virtualName=”“
explicitFocusOrder=“0” pos=“69.333% 5.333% 24% 90.667%” tooltip=“Slider2B"
min=”-100” max=“100” int=“0” style=“LinearVertical” textBoxPos="TextBoxBelow"
textBoxEditable=“1” textBoxWidth=“80” textBoxHeight=“20” skewFactor=“1”/>
</JUCER_COMPONENT>

END_JUCER_METADATA
*/
#endif

//[EndFile] You can add extra defines here…
//[/EndFile]

PluginEditor.h


/*

This is an automatically generated GUI class created by the Introjucer!

Be careful when adding custom code to these files, as only the code within
the “//[xyz]” and “//[/xyz]” sections will be retained when the file is loaded
and re-saved.

Created with Introjucer version: 3.1.0


The Introjucer is part of the JUCE library - "Jules’ Utility Class Extensions"
Copyright 2004-13 by Raw Material Software Ltd.

==============================================================================
*/

#ifndef JUCE_HEADER_EBAED77D3ADCF94F
#define JUCE_HEADER_EBAED77D3ADCF94F

//[Headers] – You can add your own extra header files here –
#include “JuceHeader.h”
//[/Headers]

//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Introjucer.

Describe your class and how it works here!
                                                                //[/Comments]

/
class OpenCvst2AudioProcessorEditor : public juce::AudioProcessorEditor,
public SliderListener
{
public:
//==============================================================================
OpenCvst2AudioProcessorEditor (OpenCvst2AudioProcessor
ownerFilter);
~OpenCvst2AudioProcessorEditor();

//==============================================================================
//[UserMethods]     -- You can add your own custom methods in this section.
//[/UserMethods]

void paint (Graphics&amp; g);
void resized();
void sliderValueChanged (Slider* sliderThatWasMoved);

private:
//[UserVariables] – You can add your own custom variables in this section.
//OpenCvstAudioProcessor* processor;
//[/UserVariables]

//==============================================================================
ScopedPointer&lt;Slider&gt; sliderA;
ScopedPointer&lt;Slider&gt; sliderB;

//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenCvst2AudioProcessorEditor)

};

//[EndFile] You can add extra defines here…
//[/EndFile]

#endif // JUCE_HEADER_EBAED77D3ADCF94F

 

PluginProcessor.cpp


/*

This file was auto-generated!

It contains the basic startup code for a Juce application.

==============================================================================
*/
#include “opencv2/objdetect/objdetect.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/imgproc/imgproc.hpp”

#include “PluginProcessor.h”
#include “PluginEditor.h”

/** Function Headers /
void detectAndDisplay(IplImage
frame );

/** Global variables /
#ifdef FIND_FACE
CvHaarClassifierCascade
face_cascade = 0;
CvMemStorage* pStorageface = 0;
#endif

#ifdef FIND_EYE
CvHaarClassifierCascade* eye_cascade = 0;
CvMemStorage* pStorageeye = 0; // memory for detector to use
#endif

#ifdef FIND_MOUTH
CvHaarClassifierCascade* mouth_cascade = 0;
CvMemStorage* pStoragemouth = 0;
#endif

#ifdef GET_HISTOGRAM
IplImage* DrawHistogram(CvHistogram hist, float scaleX=1.0, float scaleY=1.0, uchar HistColR = 255, uchar HistColG = 255, uchar HistColB = 255 )
{
float histMax = 0;
cvGetMinMaxHistValue(hist, 0, &histMax, 0, 0);
// IplImage
imgHist = cvCreateImage(cvSize(256.0scaleX, 64.0scaleY), 8 ,1);
IplImage* imgHist = cvCreateImage(cvSize(int(256.0scaleX), int(64.0scaleY)), 8 ,3);

cvZero(imgHist);
for(int i=0; i &lt; 255; i++)
{
 float histValue = cvQueryHistValue_1D(hist, i);
 float nextValue = cvQueryHistValue_1D(hist, i+1);

 CvPoint pt1 = cvPoint(int(i*scaleX), int(64.0*scaleY));
 CvPoint pt2 = cvPoint(int(i*scaleX+scaleX), int(64.0*scaleY));
 CvPoint pt3 = cvPoint(int(i*scaleX+scaleX), int((64.0-nextValue*64.0/histMax)*scaleY));
 CvPoint pt4 = cvPoint(int(i*scaleX), int((64.0-histValue*64.0/histMax)*scaleY));

 int numPts = 5;
 CvPoint pts[] = {pt1, pt2, pt3, pt4, pt1};

    //cvScalar fi = CV_RGB(HistColR, HistColG, HistColB);

// cvFillConvexPoly(imgHist, pts, numPts, cvScalar(HistColR) ); //cvScalar(255)
cvFillConvexPoly(imgHist, pts, numPts, cvScalar(HistColB, HistColG, HistColR) ); //cvScalar(255)
}
return imgHist;
}
#endif

/**

  • @function detectAndDisplay
    /
    void detectAndDisplay(IplImage
    frame )
    {
    #ifdef FIND_FACE
    CvSeq* pFaceRectSeq; // memory-access interface
    #endif
    #ifdef FIND_EYE
    CvSeq* pEyeRectSeq;
    #endif
    #ifdef FIND_MOUTH
    CvSeq* pMouthRectSeq;
    #endif

#ifdef FIND_FACE
pStorageface = cvCreateMemStorage(0);

// detect faces in image
pFaceRectSeq = cvHaarDetectObjects
    (frame, face_cascade, pStorageface,
    1.1,                       // increase search scale by 10% each pass
    3,                         // merge groups of three detections
    CV_HAAR_DO_CANNY_PRUNING | CV_HAAR_DO_ROUGH_SEARCH | CV_HAAR_SCALE_IMAGE | CV_HAAR_FIND_BIGGEST_OBJECT,  // skip regions unlikely to contain a face
    cvSize(40, 40));            // smallest size face to detect = 40x40

#endif

#ifdef FIND_EYE
pStorageeye = cvCreateMemStorage(0);

// detect faces in image
pEyeRectSeq = cvHaarDetectObjects
    (frame, eye_cascade, pStorageeye,
    1.1,                       // increase search scale by 10% each pass
    4,                         // merge groups of two detections
    CV_HAAR_DO_CANNY_PRUNING,  // skip regions unlikely to contain an eye
    cvSize(40, 40));            // smallest size face to detect = 40x40

#endif

#ifdef FIND_MOUTH
pStoragemouth = cvCreateMemStorage(0);

// detect faces in image
pMouthRectSeq = cvHaarDetectObjects
    (frame, mouth_cascade, pStoragemouth,
    1.1,                       // increase search scale by 10% each pass
    3,                         // merge groups of three detections
    CV_HAAR_DO_CANNY_PRUNING,  // skip regions unlikely to contain a mouth
    cvSize(40, 40));            // smallest size face to detect = 40x40

#endif

//const char * DISPLAY_WINDOW = “Haar Window”;
int i;

// create a window to display detected faces

// cvNamedWindow(DISPLAY_WINDOW, CV_WINDOW_AUTOSIZE);
#ifdef FIND_FACE
// draw a green rectangular outline around each face detection
for (i=0; i < (pFaceRectSeq ? pFaceRectSeq->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem(pFaceRectSeq, i);
CvPoint Fpt1 = { r->x, r->y };
CvPoint Fpt2 = { r->x + r->width, r->y + r->height };
cvRectangle(frame, Fpt1, Fpt2, CV_RGB(0, 255, 0), 3, 4, 0);

#ifdef FIND_EYE
// draw a blue rectangular outline around each eye detection
for (i=0; i < (pEyeRectSeq ? pEyeRectSeq->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem(pEyeRectSeq, i);
CvPoint Ept1 = { r->x, r->y };
CvPoint Ept2 = { r->x + r->width, r->y + r->height };
if ((Ept1.x > Fpt1.x) && (Ept2.x < Fpt2.x))
cvRectangle(frame, Ept1, Ept2, CV_RGB(0, 0, 255), 3, 4, 0);
}
#endif

#ifdef FIND_MOUTH
// draw a yellow rectangular outline around each mouth detection
for (i=0; i < (pMouthRectSeq ? pMouthRectSeq->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem(pMouthRectSeq, i);
CvPoint Mpt1 = { r->x, r->y };
CvPoint Mpt2 = { r->x + r->width, r->y + r->height };
if ((Mpt1.x > Fpt1.x) && (Mpt2.x < Fpt2.x) &&
(Mpt1.y > Fpt1.y+((Fpt2.y-Fpt1.y) / 2)) /&& (Mpt2.y < Fpt2.y+20)/)
{
cvRectangle(frame, Mpt1, Mpt2, CV_RGB(255, 255, 0), 3, 4, 0);

IplImage *mask = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
cvSetZero(mask);
//cv::Rect const mask(Mpt1.x, Mpt1.y, Mpt2.x, Mpt2.y);
cvRectangle(mask, Mpt1, Mpt2, CV_RGB(255, 255, 255), 2, 4, 0);
//cv::Mat roi = image(mask);
cvShowImage(“Mask”, mask);
//cvRelease(mask);
}
}
#endif

}

#endif

// display face detections

// cvShowImage(DISPLAY_WINDOW, frame);
#ifdef FIND_FACE
cvReleaseMemStorage(&pStorageface);
pStorageface = 0;
#endif

#ifdef FIND_EYE
cvReleaseMemStorage(&pStorageeye);
pStorageeye = 0;
#endif

#ifdef FIND_MOUTH
cvReleaseMemStorage(&pStoragemouth);
pStoragemouth = 0;
#endif
}

#ifdef APPLY_IMAGEPROCESSING
// CHANGES BRIGHTNESS AND/OR CONTRAST
// INPUT: IplImage * (nChannels=1 OR nChannels=3; IPL_DEPTH_8U)
// RETURNS: IplImage * SAME DEPTH AND CHANNELS AS INPUT

IplImage * ContrastBrightness(IplImage *src, int Contrast, int Brightness)

{
if (Contrast > 100) {Contrast = 100;} else if (Contrast < -100) {Contrast = -100;}
if (Brightness > 100) {Brightness = 100;} else if (Brightness < -100) {Brightness = -100;}

uchar lut[256];

CvMat* lut_mat;
const int hist_size = 256;
float range_0[] = {(float)0, (float)hist_size};
float* ranges[] = { range_0 };

int i;

IplImage * dest = cvCloneImage(src);

IplImage * GRAY = cvCreateImage(cvGetSize(src),src-&gt;depth,1);

if (src-&gt;nChannels == 3)
{
    cvCvtColor(src, GRAY, CV_RGB2GRAY);
}
else
{
    cvCopyImage(src, GRAY);
}

lut_mat = cvCreateMatHeader( 1, 256, CV_8UC1 );
cvSetData( lut_mat, lut, 0 );

 /*
 * The algorithm is by Werner D. Streidt
 * (http://visca.com/ffactory/archives/5-99/msg00021.html)
 */

if( Contrast &gt; 0 )

{
 double delta = 127.* Contrast/100;
 double a = 255./(255. - delta*2);
 double b = a*(Brightness - delta);
    
    for( i = 0; i &lt; 256; i++ )
    {
        int v = cvRound(a*i + b);

        if( v &lt; 0 )
            v = 0;
        if( v &gt; 255 )
            v = 255;

        lut[i] = (uchar)v;
    }
}
else
{
 double delta = -128.* Contrast/100;
 double a = (256.-delta*2)/255.;
 double b = a* Brightness + delta;

    for( i = 0; i &lt; 256; i++ )
    {
        int v = cvRound(a*i + b);
        if( v &lt; 0 )
            v = 0;

        if( v &gt; 255 )
            v = 255;

        lut[i] = (uchar)v;
    }
}

if (src-&gt;nChannels == 3)
{
    IplImage* R = cvCreateImage(cvGetSize(src), src-&gt;depth, 1);
    IplImage* G = cvCreateImage(cvGetSize(src), src-&gt;depth, 1);
    IplImage* B = cvCreateImage(cvGetSize(src), src-&gt;depth, 1);

    cvCvtPixToPlane(src, R, G, B, NULL);

    // PERFORM IT ON EVERY CHANNEL
    cvLUT( R, R, lut_mat );
    cvLUT( G, G, lut_mat );
    cvLUT( B, B, lut_mat );

    cvCvtPlaneToPix(R, G, B, NULL, dest);

    cvReleaseImage(&amp;R);
    R = 0;

    cvReleaseImage(&amp;G);
    G = 0;

    cvReleaseImage(&amp;B);
    B = 0;
}
else
{
    //PERFORM IT ON THE CHANNEL
    cvLUT( GRAY, dest, lut_mat );
}

cvReleaseImage(&amp;GRAY);
GRAY = 0;
cvReleaseMat( &amp;lut_mat);
lut_mat = 0;
return dest;

}
#endif

//==============================================================================
OpenCvst2AudioProcessor::OpenCvst2AudioProcessor()
{
// KEY LINE: Start the window thread
cvStartWindowThread();

 //initialize and allocate memory to load the video stream from camera
 /*CvCapture **/capture = cvCaptureFromCAM(0);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 128);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 128);
cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, IPL_DEPTH_32F);

/// IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_32F, 1 );
//// if( !capture ) return 1;

 //create a window with the title "Video"
cvNamedWindow("Video", CV_WINDOW_AUTOSIZE );

#ifdef APPLY_IMAGEPROCESSING
cvNamedWindow(“Processed”, CV_WINDOW_AUTOSIZE );
#endif
#ifdef GET_HISTOGRAM
cvNamedWindow(“Red”, CV_WINDOW_AUTOSIZE );
cvNamedWindow(“Green”, CV_WINDOW_AUTOSIZE );
cvNamedWindow(“Blue”, CV_WINDOW_AUTOSIZE );
#endif

//-- 1. Load the cascade
#ifdef FIND_FACE
face_cascade = (CvHaarClassifierCascade *)cvLoad(“C:\SDKs\NewOpenCV\sources\data\haarcascades\haarcascade_frontalface_default.xml”, 0 , 0, 0);
jassert(face_cascade != 0);

#endif
#ifdef FIND_EYE
eye_cascade = (CvHaarClassifierCascade *)cvLoad(“C:\SDKs\NewOpenCV\sources\data\haarcascades\haarcascade_eye_tree_eyeglasses.xml”, 0 , 0, 0);
jassert(eye_cascade != 0);

#endif
#ifdef FIND_MOUTH
mouth_cascade = (CvHaarClassifierCascade *)cvLoad(“C:\Users\Andrew Cordani\Documents\Devel\OpenCVST2\mouth.xml”);
jassert(mouth_cascade != 0);

#endif
}

OpenCvst2AudioProcessor::~OpenCvst2AudioProcessor()
{
// When playback stops, you can use this as an opportunity to free up any
// Use this method as the place to do any pre-playback
// cvWaitKey(1);

// spare memory, etc.
   //destroy the opened window

cvDestroyWindow(“Video”);
//cvDestroyWindow(“Dilated”);

#ifdef APPLY_IMAGEPROCESSING
cvDestroyWindow(“Processed”);
#endif

#ifdef GET_HISTOGRAM
cvDestroyWindow(“Blue”);
cvDestroyWindow(“Green”);
cvDestroyWindow(“Red”);
#endif
cvReleaseCapture( &capture );

 // clean up and release resources
cvReleaseImage(&amp;frame);

#ifdef FIND_FACE
if (face_cascade) cvReleaseHaarClassifierCascade(&face_cascade);
face_cascade = 0;
if (pStorageface) cvReleaseMemStorage(&pStorageface);
pStorageface = 0;
#endif

#ifdef FIND_EYE
if (eye_cascade) cvReleaseHaarClassifierCascade(&eye_cascade);
eye_cascade = 0;
if (pStorageeye) cvReleaseMemStorage(&pStorageeye);
pStorageeye = 0;
#endif

#ifdef FIND_MOUTH
if (mouth_cascade) cvReleaseHaarClassifierCascade(&mouth_cascade);
mouth_cascade = 0;
if (pStoragemouth) cvReleaseMemStorage(&pStoragemouth);
pStoragemouth = 0;
#endif
cvDestroyAllWindows(); // incase I’ve forgotten any
}

//==============================================================================
const String OpenCvst2AudioProcessor::getName() const
{
return JucePlugin_Name;
}

int OpenCvst2AudioProcessor::getNumParameters()
{
return 2;
}

float OpenCvst2AudioProcessor::getParameter (int index)
{
switch (index)
{
case 0: return brightness;
break;
case 1: return contrast;
break;
default:
//ASSERT;
return -99.0;
break;
}
}

void OpenCvst2AudioProcessor::setParameter (int index, float newValue)
{
switch (index)
{
case 0: brightness = newValue;
break;
case 1: contrast = newValue;
break;
default:
//ASSERT;
break;
}
}

const String OpenCvst2AudioProcessor::getParameterName (int index)
{
switch (index)
{
case 0: return String(“Brightness Name”);
break;
case 1: return String(“Contrast Name”);
break;
default:
return String(“Unknown Name”);
break;
}
}

const String OpenCvst2AudioProcessor::getParameterText (int index)
{
switch (index)
{
case 0: return String(“Brightness” + String(brightness));
break;
case 1: return String(“Contrast Text” + String(contrast));
break;
default:
return String(“Unknown Text”);
break;
}
}

const String OpenCvst2AudioProcessor::getInputChannelName (int channelIndex) const
{
return String (channelIndex + 1);
}

const String OpenCvst2AudioProcessor::getOutputChannelName (int channelIndex) const
{
return String (channelIndex + 1);
}

bool OpenCvst2AudioProcessor::isInputChannelStereoPair (int index) const
{
index = index;
return true;
}

bool OpenCvst2AudioProcessor::isOutputChannelStereoPair (int index) const
{
index = index;
return true;
}

bool OpenCvst2AudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}

bool OpenCvst2AudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}

bool OpenCvst2AudioProcessor::silenceInProducesSilenceOut() const
{
return false;
}

double OpenCvst2AudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}

int OpenCvst2AudioProcessor::getNumPrograms()
{
return 0;
}

int OpenCvst2AudioProcessor::getCurrentProgram()
{
return 0;
}

void OpenCvst2AudioProcessor::setCurrentProgram (int index)
{
index = index;
}

const String OpenCvst2AudioProcessor::getProgramName (int index)
{
index = index;

return String::empty;

}

void OpenCvst2AudioProcessor::changeProgramName (int index, const String& newName)
{
index = index;
}

//==============================================================================
void OpenCvst2AudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
// Use this method as the place to do any pre-playback
samplesPerBlock = samplesPerBlock;
cvWaitKey(1);

// initialisation that you need..

}

void OpenCvst2AudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.

cvWaitKey(1);

//release memory
cvReleaseImage( &frame );
frame = 0;
// cvReleaseImage( &dst );
}

void OpenCvst2AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
double alpha = 100.0 / (100.0 + (2.0 * this->contrast)); /< Simple contrast control */
int beta = this->brightness; /
< Simple brightness control */

// while(true) {
//grab and retrieve each frames of the video sequentially
/IplImage*/ frame = cvQueryFrame( capture );
if( frame )
{

         ///IplImage *img =  cvQueryFrame( capture );
         ///if (!img ) break;

// cvErode(frame, frame, 0, brightness);

/*
cv::Mat new_image = cv::Mat::zeros( frame->size(), frame->type() );

/// Do the operation new_image(i,j) = alphaimage(i,j) + beta
for( int y = 0; y < frame->rows; y++ )
{
for( int x = 0; x < frame->cols; x++ )
{
for( int c = 0; c < 3; c++ )
{
new_image.at<cv::Vec3b>(y,x)[c] =
cv::saturate_cast<uchar>( alpha
( frame->at<cv::Vec3b>(y,x)[c] ) + beta );
}
}
}
*/

#ifdef GET_HISTOGRAM
int numBins = 256;
float range[] = {0, 255};
float *ranges[] = { range };

CvHistogram *hist = cvCreateHist(1, &amp;numBins, CV_HIST_ARRAY, ranges, 1);
cvClearHist(hist);

IplImage* imgRed = cvCreateImage(cvGetSize(frame), 8, 1);
IplImage* imgGreen = cvCreateImage(cvGetSize(frame), 8, 1);
IplImage* imgBlue = cvCreateImage(cvGetSize(frame), 8, 1);

IplImage* imgChanged = cvCreateImage(cvGetSize(frame), 8, 1);
imgChanged = ContrastBrightness(frame, contrast, brightness);

cvSplit(imgChanged, imgBlue, imgGreen, imgRed, NULL);

cvCalcHist(&amp;imgRed, hist, 0, 0);
IplImage* imgHistRed = DrawHistogram(hist, 1.0F,1.0F, 255,0,0);
cvClearHist(hist);

cvCalcHist(&amp;imgGreen, hist, 0, 0);
IplImage* imgHistGreen = DrawHistogram(hist, 1.0F,1.0F, 0,255,0);
cvClearHist(hist);

cvCalcHist(&amp;imgBlue, hist, 0, 0);
IplImage* imgHistBlue = DrawHistogram(hist, 1.0F,1.0F, 0,0,255);
 cvClearHist(hist);

 cvShowImage("Green", imgHistGreen);
cvShowImage("Red", imgHistRed);
cvShowImage("Blue", imgHistBlue);

cvReleaseImage (&amp;imgRed );
imgRed = 0;
cvReleaseImage (&amp;imgGreen );
imgGreen = 0;
cvReleaseImage (&amp;imgBlue );
imgBlue = 0;

cvReleaseImage (&amp;imgHistRed);
imgHistRed = 0;
cvReleaseImage (&amp;imgHistGreen);
imgHistGreen = 0;
cvReleaseImage (&amp;imgHistBlue);
imgHistBlue = 0;

/**/
#else
////////////////////////////////////////////////////////// IplImage* imgChanged = frame;
#endif

#ifdef APPLY_IMAGEPROCESSING
detectAndDisplay(imgChanged);
#endif
//show the retrieved frame in the “Video” window
cvShowImage( “Video”, frame );
#ifdef APPLY_IMAGEPROCESSING
cvShowImage( “Processed”, imgChanged );
cvReleaseImage(&imgChanged);
#endif

//dilate and display the dilated image
            //cvDilate(img, img, 0, 2);
            //cvNamedWindow("Dilated");
            //cvShowImage("Dilated", img);


         //wait for 40 milliseconds
        // int c = cvWaitKey(1);
   
      //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27)
      //if((char)c==27 ) break;

         }

// }

// This is the place where you'd normally do the guts of your plugin's
// audio processing...
for (int channel = 0; channel &lt; getNumInputChannels(); ++channel)
{
    float* channelData = buffer.getSampleData (channel);

    // ..do something to the data...
}

// In case we have more outputs than inputs, we'll clear any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
for (int i = getNumInputChannels(); i &lt; getNumOutputChannels(); ++i)
{
    buffer.clear (i, 0, buffer.getNumSamples());
}

}

//==============================================================================
bool OpenCvst2AudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}

AudioProcessorEditor* OpenCvst2AudioProcessor::createEditor()
{
return new OpenCvst2AudioProcessorEditor (this);
}

//==============================================================================
void OpenCvst2AudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}

void OpenCvst2AudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}

//==============================================================================
// This creates new instances of the plugin…
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new OpenCvst2AudioProcessor();
}

PluginProcessor.h


/*

This file was auto-generated!

It contains the basic startup code for a Juce application.

==============================================================================
/
//[Headers] You can add your own extra header files here…
/
* HELLO WORLD
#include “opencv\cv.h”
#include "opencv\highgui.h"
using namespace cv;
**/

#include <cv.h>
#include <highgui.h>

#define APPLY_IMAGEPROCESSING
#define GET_HISTOGRAM
#define FIND_FACE
//#define FIND_EYE
#define FIND_MOUTH

//[/Headers]

#ifndef PLUGINPROCESSOR_H_INCLUDED
#define PLUGINPROCESSOR_H_INCLUDED

#include “…/JuceLibraryCode/JuceHeader.h”

//==============================================================================
/**
*/
class OpenCvst2AudioProcessor : public AudioProcessor
{
public:
//==============================================================================
OpenCvst2AudioProcessor();
~OpenCvst2AudioProcessor();

//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock);
void releaseResources();

void processBlock (AudioSampleBuffer&amp; buffer, MidiBuffer&amp; midiMessages);

//==============================================================================
AudioProcessorEditor* createEditor();
bool hasEditor() const;

//==============================================================================
const String getName() const;

int getNumParameters();

float getParameter (int index);
void setParameter (int index, float newValue);

const String getParameterName (int index);
const String getParameterText (int index);

const String getInputChannelName (int channelIndex) const;
const String getOutputChannelName (int channelIndex) const;
bool isInputChannelStereoPair (int index) const;
bool isOutputChannelStereoPair (int index) const;

bool acceptsMidi() const;
bool producesMidi() const;
bool silenceInProducesSilenceOut() const;
double getTailLengthSeconds() const;

//==============================================================================
int getNumPrograms();
int getCurrentProgram();
void setCurrentProgram (int index);
const String getProgramName (int index);
void changeProgramName (int index, const String&amp; newName);

//==============================================================================
void getStateInformation (MemoryBlock&amp; destData);
void setStateInformation (const void* data, int sizeInBytes);
CvCapture *capture;
IplImage* frame;

private:
float brightness;
float contrast;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenCvst2AudioProcessor)
};

#endif // PLUGINPROCESSOR_H_INCLUDED

I haven't included the OpenCV files