GrabFrame() to return a string of pixel information?

Hi everyone,
Basically what im looking for is creating a 2d array of values(but id be happy with a string) corrosponding to each of the 320*240 pixels of my camera. At the moment i can get back an awt image using:
Buffer buf = frameGrabber.grabFrame();
Image img = (new BufferToImage((VideoFormat) buf.getFormat()).createImage(buf));
I would of thought that i should meerly use the toString() method. But if i toString() buf i get:
javax.media.Buffer@22c95b
and if i toString() img i get:
BufferedImage@22c95b: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 320 height = 240 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
If anyone could help, and point me in the direction of the right method to use, i would be greatly appreciative.
Thanks.

You will need integer values from an image to do anything meaningful with the data. Something like this -
int redValues = new int[imageWidth * imageHeight];
int greenValues  = new int[imageWidth * imageHeight];
int blueValues  = new int[imageWidth * imageHeight];
int alphaValues  = new int[imageWidth * imageHeight];
int counter = 0;
public void grabEveryPixelInThe Image(Image img, int x, int y, int w, int h) {
        int[] pixels = new int[w * h];
        PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
        try {
            pg.grabPixels();
        } catch (InterruptedException e) {
            System.err.println("interrupted waiting for pixels!");
            return;
        if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
            System.err.println("image fetch aborted or errored");
            return;
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                doOnePixel(pixels[j * w + i]);
public void doOnePixel( int pixel) {
        int alpha = (pixel >> 24) & 0xff;
        int red   = (pixel >> 16) & 0xff;
        int green = (pixel >>  8) & 0xff;
        int blue  = (pixel      ) & 0xff;
       redValues[ counter] = red ;
       greenValues [ counter] = green ;
       blueValues  [ counter] = blue ;
       AlphaValues [ counter ] = alpha ;
       counter++;
}regards

Similar Messages

  • Min aggregate function returns empty string

    I have a data set with a column named "month" which contains string values like 1,2,3... etc. including empty string. When I apply an aggregate Min function like below, it returns empty string instead of 1. or the lowest month number.
    Min(Fields!month.Value, "Financial")
    Please if any one can assist me on this.
    Regards

    Hi ABDUL-HAFEEZ,
    As you know the Min() function returns the minimum value of all non-null numeric values specified by the expression, because you have null string in the field and also the field type is string but not numeric, so this function will not works fine.
    I have tested on my local environment that we can get the first convert the string to numeric type value and then get the min value of the month field by using the query not the expression.
    Details information below for your reference:
    Create an new dataset(DataSet2) to get the minimum value from the Month and the query like below:
    SELECT     Min(CAST(Month AS INT)) as NewMonth
    FROM         TableName
    Using below expression in the main dataset will display the minimum value of the month:
    =Sum(Fields!NewMonth.Value, "DataSet2")
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • How do I open a .nrl extension in firefox, currently it returns a string of text instead of opening the file with the default program.

    When I click on a .nrl file extension (belongs to Autonomy I-Manage Software) it returns a string of code (what is in the shortcut link) instead of following the link and returning the document. Is there a way to tell Forefox connect to the document that the shortcut is linked to? The .nrl file extension belongs to a piece of software called FileSite (document management system).

    '''Adding download actions''' is the relevant section of that article for your situation.
    Is the *.nrl file on a website or already saved to your PC?
    If it is on a website, the server may not be sending the appropriate Mime-Type telling Firefox how that file is to be handled - ''"Content-Disposition"''.
    Can you give us the URL of the webpage where you have this problem? <br />
    So we can see first hand what the issue is.

  • Returning XML String From Servlet

              Is there a simple way to disable the HTML character escaping when returning
              a string from a servlet. The returned string contains well formed XML, and
              I don't want the tags converted to > and < meta characters in the
              HTTP reply.
              The code is basically "hello world", version 7.0 SP2.
              Thanks
              > package xxx.servlet;
              >
              > import weblogic.jws.control.JwsContext;
              >
              >
              > /**
              > * @jws:protocol http-xml="true" form-get="false" form-post="false"
              > */
              > public class HelloWorld
              > {
              > /** @jws:context */
              > JwsContext context;
              >
              > /**
              > * @jws:operation
              > * @jws:protocol http-xml="false" form-post="true" form-get="false" soap-s
              tyle="document"
              > * @jws:return-xml xml-map::
              > * <HelloWorldResponse xmlns="http://www.xxx.com/">
              > * {return}
              > * </HelloWorldResponse>
              >
              > * ::
              > * @jws:parameter-xml xml-map::
              > * <HelloWorld xmlns="http://www.xxx.com/">
              > * <ix>{ix}</ix>
              > * <contents>{contents}</contents>
              > * </HelloWorld>
              >
              > * ::
              > */
              > public String HelloWorld(String s)
              > {
              > return "<a> xyz </a>";
              > }
              > }
              

              Radha,
              We have a client/server package which speaks SOAP over a
              streaming HTTP channel for which we are writing a WebLogic
              servlet. For reasons of efficiency, we want to deserialize
              only the very top-level tags of the messages as they pass
              through the servlet. Yes, in theory, we should probably
              deserialize and validate the entire message contents...
              When we add support for other clients, we will fully
              deserialize inside those servlets.
              I have not looked any further into how to stop the inner
              tags from being escaped yet -- it is an annoyance more than
              a disaster, since the client handle meta escapes.
              My current guess is to use ECMAScript mapping...
              -Tony
              "S.Radha" <[email protected]> wrote:
              >
              >"Tony Hawkins" <[email protected]> wrote:
              >>
              >>Is there a simple way to disable the HTML character escaping when returning
              >>a string from a servlet. The returned string contains well formed XML,
              >>and
              >>I don't want the tags converted to > and < meta characters in the
              >>HTTP reply.
              >>
              >>The code is basically "hello world", version 7.0 SP2.
              >
              >>
              >>Thanks
              >>
              >>> package xxx.servlet;
              >>>
              >>> import weblogic.jws.control.JwsContext;
              >>>
              >>>
              >>> /**
              >>> * @jws:protocol http-xml="true" form-get="false" form-post="false"
              >>> */
              >>> public class HelloWorld
              >>> {
              >>> /** @jws:context */
              >>> JwsContext context;
              >>>
              >>> /**
              >>> * @jws:operation
              >>> * @jws:protocol http-xml="false" form-post="true" form-get="false"
              >>soap-s
              >>tyle="document"
              >>> * @jws:return-xml xml-map::
              >>> * <HelloWorldResponse xmlns="http://www.xxx.com/">
              >>> * {return}
              >>> * </HelloWorldResponse>
              >>>
              >>> * ::
              >>> * @jws:parameter-xml xml-map::
              >>> * <HelloWorld xmlns="http://www.xxx.com/">
              >>> * <ix>{ix}</ix>
              >>> * <contents>{contents}</contents>
              >>> * </HelloWorld>
              >>>
              >>> * ::
              >>> */
              >>> public String HelloWorld(String s)
              >>> {
              >>> return "<a> xyz </a>";
              >>> }
              >>> }
              >>
              >>
              >Hi Tony,
              >
              > Can you let me know for what purpose you want to disable the
              >HTML character
              >escaping.In case if you
              >
              >have tried this using someway,pl. let me know.
              >
              >rgds
              >Radha
              >
              >
              

  • Queue returns blank strings from template VI

    I have created a master VI which creates a named queue, this VI then spawns multiple copies of a template VI. These sub VIs all gain access to the queue and try writing data to it. I understood that the queue VI was protected so this should not cause a problem. Infact this does not work at all, when i extract element within the master VI it only finds a few of the elements and returns blank strings between. Help what is going on. I am not destroying the queue or such, it seems to be a problem with the protection of the queue when using template VIs.
    Cheers Tom.

    I have not been able to reproduce the problem on LV 6.0.2 Win98. Do you check the error cluster when an empty element is returned? Posting your code might help to find the problem.
    LabVIEW, C'est LabVIEW

  • WINE err:"wine cmd.exe /c echo '%ProgramFiles%' returned empty string"

    So as the tittle states WINE is throiwng this error:
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    As for what might have caused it? probably the last system update which was performed a few days ago, my old prefix works fine but I have a habit of creating new prefixes for troublesome applications, or applications I am unsure of whether they will cause trouble or not.
    Hence I created a new prefix using:
    export WINEARCH=win32
    export WINEPREFIX=~/.problematic
    winecfg
    As for how wine is run, it's run as a normal, unprivileged, user.
    Oh and I also tried generating yet another prefix like this:
    $ WINEARCH=win32 WINEPREFIX=~/.problematic-new winetricks steam
    Executing w_do_call steam
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    Didn't work either.
    I'm at loss, any suggestion on how to fix it?
    Last edited by CubeGod (2014-06-29 15:48:05)

    $ WINEARCH=win32 WINEPREFIX=~/testprefix notepad.exe
    bash: notepad.exe: command not found
    So obviously I need to correct the command
    $ WINEARCH=win32 WINEPREFIX=~/testprefix wine notepad.exe
    wine: created the configuration directory '/home/shiina/testprefix'
    err:module:load_builtin_dll failed to load .so lib for builtin L"winemp3.acm": libmpg123.so.0: cannot open shared object file: No such file or directory
    fixme:ntdll:NtLockFile I/O completion on lock not implemented yet
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    err:mscoree:LoadLibraryShim error reading registry key for installroot
    fixme:ntdll:NtLockFile I/O completion on lock not implemented yet
    fixme:iphlpapi:NotifyAddrChange (Handle 0xece880, overlapped 0xece88c): stub
    wine: configuration in '/home/shiina/testprefix' has been updated.
    Wine cannot find the ncurses library (libncursesw.so.5).
    why is ncurses a dependency anyway? besides, wicd-curses works so this shouldn't be the case.
    Anyway, trying winetricks in the same prefix
    $ WINEARCH=win32 WINEPREFIX=~/testprefix winetricks steam
    Executing w_do_call steam
    wine cmd.exe /c echo '%ProgramFiles%' returned empty string
    Anyway, I expected notepad to work since it resides in %WINDOWS% not %ProgramFiles%
    Is there any registry key I can set for this? all my google searching says this can cause with a mismatch of wine versions but why would that happen?
    Either way checking wine --version outputs wine-1.7.20 which is the same as it was pre-update (when it still worked).

  • Calling c function that return a string

    Hallo,
    I found an example for calling void c function(http://zone.ni.com/devzone/cda/epd/p/id/1513). I could adapt the example and make the function return an integer. the code of the adapted function would look like this:
     int __declspec(dllexport) multiply(int number) {return number*3; }
    But I have problems when I want to return a string. Does someone knows how I should do. I tried:
     char* __declspec(dllexport) say(int number) {return "hallo"; }  
    but won't compile.

    yes the question was  more a c question then a labview question. I found the solution anyway, the correct code in order to get string is:
    _declspec(dllexport) char* testchar2();_declspec(dllexport) char* testchar2() {      return "hallo"; }

  • Error returning large String arrays from web service

    Hi,
    I currently have an EJB that returns a String[] array that I have implemented as
    a Web Service. When I execute a Java client (JSP) from Weblogic, I don't have a problem
    as long as the returned array is relatively small, but when the array starts to get
    a little larger (say 20 elements, about 30 chars each), I consistently get:
    SAXException: java.lang.IllegalArgumentException:array element type mismatch.
    Strangely enough, when my web service client is a .asp page running under MS IIS
    (using the MS SOAP Toolkit), it works fine. I have returned as many as 15000 - 20000
    array elements in one call. And since I am calling the same Weblogic EJB with the
    MS client, I know it's a problem with the Java client, not the EJB.
    Anybody know of a bug or had this experience before? Or know what I might be doing
    wrong? FYI, I am using Weblogic 6.1 SP2.
    Thanks,
    Steve

    Hi Steve,
    Sure we're interested...I'll pass this along to the XML folks.
    Thanks for the feedback,
    Bruce
    Steve Alexander wrote:
    In case anyone is interested, I solved my problem. I was mis-diagnosing the problem
    - thinking it was a size issue when it actually was a data issue. On the calls where
    I was returning a large array, some of the array members were null. When I made them
    enpty strings "", it worked. Apparently the default SAX parser BEA uses doesn't like
    the nulls, whereas the MS parser doesn't care.
    "Steve Alexander" <[email protected]> wrote:
    Thanks Bruce,
    FYI - I have reproduced the problem on WL7.0. I have turned it in to support
    as you
    suggested.
    Steve
    Bruce Stephens <[email protected]> wrote:
    Hi Steve,
    This does not ring any bells, however I would suggest that you file a support
    case. If it
    is an option you might try a later release (7.0).
    Bruce
    Steve Alexander wrote:
    Hi,
    I currently have an EJB that returns a String[] array that I have implementedas
    a Web Service. When I execute a Java client (JSP) from Weblogic, I don'thave a problem
    as long as the returned array is relatively small, but when the arraystarts to get
    a little larger (say 20 elements, about 30 chars each), I consistentlyget:
    SAXException: java.lang.IllegalArgumentException:array element type mismatch.
    Strangely enough, when my web service client is a .asp page running underMS IIS
    (using the MS SOAP Toolkit), it works fine. I have returned as many as15000 - 20000
    array elements in one call. And since I am calling the same Weblogic
    EJB
    with the
    MS client, I know it's a problem with the Java client, not the EJB.
    Anybody know of a bug or had this experience before? Or know what I mightbe doing
    wrong? FYI, I am using Weblogic 6.1 SP2.
    Thanks,
    Steve

  • Returning the string from the SimpleDateFormat

    Hi guys,
    Can someone tell me how to return the string from the SimpleDateFormat?
    I've created the method to do this, but i don't know the exact code to use. Here's my code so far...
        public String convert (Calendar gc)
            String s = convert(gc);
            return // I need to return the s here, but don't know how to code it.
        }BTW, i've already wrote the code for the SimpleDateFormat (so if you want me post that, i will).

    DrLaszloJamf wrote:
    LevelSix wrote:
    DrLaszloJamf wrote:
    No.Can you tell me what it is, because i've went through the API and i don't know.
    Have you looked for a tutorial: [http://java.sun.com/docs/books/tutorial/i18n/format/dateintro.html]
    Thanks a lot DrLaszloJamf, this is useful.
    DrClap wrote:
    Nope. Suppose you were on a construction site and the foreman told you to move a pile of concrete blocks from a truck into the building. What do you suppose would happen if you asked the foreman what a concrete block was, and where the building was, and whether you should drive the truck into the street, and then you tried to pick up the whole pile all at once, and then you asked if you could kick the blocks like footballs? This is what you're doing here. You'd be fired from the construction site within half an hour.Sir...

  • Import CSV Is Incorrect - Misinterprets RETURN within Strings as New Row

    When importing a CSV file into Numbers 3.0.1, it produces bad results, because it interprets RETURNs within strings as new rows, when it should ignore them.
    How can this be worked around?

    If the CSV is properly formatted and the strings that have the carriage return(s) are enclosed in quotes, it works fine  (at least it does for me). If the strings do not have quotes around them, the returns should be interpreted as a new row.
    The workaround would be to somehow get quotes around those strings before importing into Numbers. I'm not sure how to do that except manually in a text editor or for the app that created the CSV to format it correctly.

  • External Procedure Returns Bad String

    Hello,
    I have an strange issue. I have an external procedure that returns an string but when i call it Oracle gets an string of zero's ascii chars. The length it`s ok but the content not.... The wrapper function is
    PROCEDURE getString(returnValue OUT VARCHAR2) AS
    LANGUAGE C
    LIBRARY "UFDs"
    NAME "getString"
    WITH CONTEXT
    PARAMETERS (
    context,
    returnValue STRING,
    returnValue INDICATOR short,
    returnValue LENGTH int
    And the C code is
    DLLIMPORT void getString(OCIExtProcContext* context,
    char* returnValue,
    short* returnValue_ind,
    int* returnValue_len )
    returnValue = (char*)OCIExtProcAllocCallMemory(context, 13);
    //returnValue[0] = '\0';
    strcpy(returnValue,"hello from c");
    /* I have test this to gen a file an the string is OK
    char buffer[500];
    strcpy(buffer,"echo ");
    strcat(buffer,returnValue);
    strcat(buffer," >c:\\sal.txt");
    system(buffer);
    *returnValue_len = strlen(returnValue);
    *returnValue_ind = (short)OCI_IND_NOTNULL;
    return;
    When i call this from oracle i get an string of size 12 but the string has invalid chars (zero ascii chars). Could it be a problem with charset conversion? Anybody has an example or idea?.
    Regards

    Can you please post your query / stored procedure you are using? Very possible reason includes one among your substring (within the concat) is null and making the final output to be null. Size, esp 800 shouldn't matter.

  • WebService Returning a String

    Maybe I should know this but:
    I'm calling a method of a webservice that returns a string.
    Works great.
    The string is essentially an XML document, but how can I use
    that data (the string being returned from the call) or place that
    data in a properly formatted XML? Because right now I'm getting
    back one long string .. it's an Object but I want it to be
    XML.

    See this FB 2.0.1 help topic:
    Handling results as XML with the e4x result format
    http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=dataservices_099_17.html
    <mx:WebService
    id="WS"
    destination="stockservice" useProxy="true"
    fault="Alert.show(event.fault.faultString), 'Error'">
    <mx:operation name="GetQuote" resultFormat="e4x">
    <mx:request>
    <symbol>ADBE</symbol>
    </mx:request>
    </mx:operation>
    </mx:WebService>

  • Returning List String or String[][] in JNI

    Hi,
    I am calling a native function in C++ from Java which has to return List<String> or String[][]. Is this possible?
    The java declaration is - private native List<String> GetListNative();
    In C++ the declaration is:
    JNIEXPORT jobject JNICALL Java_com_GetListNative
    (JNIEnv *env, jobject obj);
    Please help!
    Thanks in advance...
    Message was edited by:
    arjundg

    try treating String[][] as array of arrays of strings
    I mean consider your 2D array as a 1D array and each of its elements is an array of Strings
    I think this will work

  • LicenseServer property in Company object alway return empty string

    Hi everyone,
    When I use Company object and LicenseServer property to get LicenseServer, both in SBO 2004 & SBO 2005 all return empty string, who can help me get the correct LicenseServer name.
    Thanks in advance.
    Kathy

    Jose Xabier,
    Thanks for your reply, actually I need the License server name, but in SLIC table it saves Local hotost and port number some times like below:
    [localhost:30000]
    who knows how to get the name instead of Localhost,
    why licenseserver return empty sting? doI need set other property to get license server name for company object?
    Thanks,
    Kathy

  • How to return a string or a comment through ODI os command

    Hi,
    Is there any way so to return any string through odi os command.
    I want to return that error back through odi operator.
    Thanks

    I dont think so. You can modify your script file so that in case of any error it will write a flag (your string values) to another temp file (temp.txt)
    Then read the file via jython. If flag =1 (or your req values) then there is some error in your script. Now Raise error in odi which print the string in operator.
    Thanks.
    Bhabani
    http://dwteam.in

Maybe you are looking for

  • In a query, how to display the calendar day and the weekday in the heading

    Hi Experts, I am in a situation where I need to have calendar day and the weekday in a heading of a column in a query? we are in BW 3.5. Here is an example:                      04.22.2007                      Sun Branch 001      1,000.00 Branch 002 

  • Error taking CR2 image to Photoshop CS2

    Using LR v1 & WIn XPPro Am in the develop module, click on Ctrl E, In the pop up the only option I have is Edit a copy with Lightroom adjustments, click on Edit & a 2nd window saying "Lightroom was unable to prepare the selected file < filename> for

  • TV Out to View Web Pages?

    Hi, I recently purchased an Apple AV Composite cable in order to view web pages (Powerpoint presentations, documents, etc) from my iPhone on a TV or digital projector. I'm a teacher and this would be INCREDIBLY USEFUL for both meetings and classes, e

  • MIRO Posting against wrong payment,as against default vendor payment terms

    MIRO Posting against wrong payment,as against default vendor payment terms

  • Reader XI does not diplay PDF-file

    I am unable to view this PDF with Adobe Reader: http://velorooms.com/files/teamgen.pdf It only shows white page page when opened. The result is same with both viewing it on Reader program and on browser. All other PDF files work well with Reader. I a