Detecting an object in an image

hi all
i need to know how to detect a particular object like a ball or a rectangular block within an image
i tried opencv but it failed to detect an object within an image the C code used in JNI is given below
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "sift.h"
#include "imgfeatures.h"
#include "kdtree.h"
#include "utils.h"
#include "xform.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include "helloworld_HelloWorld.h"
#define KDTREE_BBF_MAX_NN_CHKS 200
/* threshold on squared ratio of distances between NN and 2nd NN */
#define NN_SQ_DIST_RATIO_THR 0.49
/******************************** Globals ************************************/
char img1_file[] = "..\\football.png";
char img2_file[] = "..\\sift.png";
JNIEXPORT jint JNICALL
Java_helloworld_HelloWorld_printNat(JNIEnv *env, jobject obj)
IplImage * img1, * img2, * stacked;
     struct feature* feat1, * feat2, * feat;
     struct feature** nbrs;
     struct kd_node* kd_root;
     CvPoint pt1, pt2;
     double d0, d1;
     int n1, n2, k, i, m = 0;
     img1 = cvLoadImage( img1_file, 1 );
     if( ! img1 )
          fatal_error( "unable to load image from %s", img1_file );
     img2 = cvLoadImage( img2_file, 1 );
     if( ! img2 )
          fatal_error( "unable to load image from %s", img2_file );
     stacked = stack_imgs( img1, img2 );
     fprintf( stderr, "Finding features in %s...\n", img1_file );
     n1 = sift_features( img1, &feat1 );
     fprintf( stderr, "Finding features in %s...\n", img2_file );
     n2 = sift_features( img2, &feat2 );
     kd_root = kdtree_build( feat2, n2 );
     for( i = 0; i < n1; i++ )
          feat = feat1 + i;
          k = kdtree_bbf_knn( kd_root, feat, 2, &nbrs, KDTREE_BBF_MAX_NN_CHKS );
          if( k == 2 )
               d0 = descr_dist_sq( feat, nbrs[0] );
               d1 = descr_dist_sq( feat, nbrs[1] );
               if( d0 < d1 * NN_SQ_DIST_RATIO_THR )
                    pt1 = cvPoint( cvRound( feat->x ), cvRound( feat->y ) );
                    pt2 = cvPoint( cvRound( nbrs[0]->x ), cvRound( nbrs[0]->y ) );
                    pt2.y += img1->height;
                    cvLine( stacked, pt1, pt2, CV_RGB(255,0,255), 1, 8, 0 );
                    m++;
                    feat1.fwd_match = nbrs[0];
          free( nbrs );
     fprintf( stderr, "Found %d total matches\n", m );
     cvNamedWindow( "Matches", 1 );
     cvShowImage( "Matches", stacked );
     cvWaitKey( 0 );
cvReleaseImage( &stacked );
     cvReleaseImage( &img1 );
     cvReleaseImage( &img2 );
     kdtree_release( kd_root );
     free( feat1 );
     free( feat2 );
     return m;
i donot want help exactly with opencv but a java code to detect an object within an image will be helpful and
help on any modification i can make on the above program will be also helpful
thank u                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Hi friend!
I have the following issue:
I'm trying to build a C++ DLL that uses OpenCV.
But when I try to compile, I have the following errors:
[Link Error] undefined reference to 'cvQueryFrame'
[Link Error] undefined reference to 'cvReleaseCapture'
[Link Error] undefined reference to 'cvReleaseImage'
I'm using Dev-C++, and I set all the libraries directories correctly. If I try to compile an .exe file that uses OpenCV, it compiles successfully.
Please help me! I'm getting "crazy" with that...

Similar Messages

  • DETECT THE OBJECT IN MONOCHROME IMAGE

    I want to detect an extra object present in my product but it has the same color as the background.  using thresholding and  particle analysis i got the detection but the resulting values are too small that sometimes this procedure leads me to  make the false rejection for my products.
    In the attachment one of the good image and a bad image i.e. image with the extra object are provided. 
    Attachments:
    good.png ‏563 KB
    bad.png ‏575 KB

    It looks like the defective side has a distinct bright line.  If most defects are similar to this, you could use a Find Edge tool and just set the limits so if any edge is found, call it a reject.  If no edges are found, then call it good.  This really depends upon how consistant your background is.
    The other option might be to count pixel values in the 200 to 255 range with a region of interest (ROI) set in this area.  Then, set a limit based on a good part background (say no more than 20 pixels found in a ROI that contains 500 or so total pixels).  I've used this method in the past, but the set limit is quite sensitive to the area of the ROI is low contrast conditions.   

  • How to detect the size of an image

    Hi,
    I have a servlet which grabs an image (jpg or gif) from a BLOB stored in my database and sents the image back to the client through the ServletOutputStream. This all works good and the image is presented nicely. However, I now want to have my servlet detect the size of the image, and if it is too big resize the image and return it.
    As I am new to images in JAVA I am unsure how to do this and what tools to use for it. I found some information on JAI, but this seems way to elaborate for what I need. Please let me know if anyone knows how to do this.
    Thank you and regards,
    Joost Schouten

    This code figures out the size of any object in bytes. I am not sure about resizing the image though..
    public int getSerializedSize(Object object)
           try
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(baos);
              oos.writeObject(object);
              byte[] bytes = baos.toByteArray();
              oos.close();
              baos.close();
              return bytes.length;
           catch(Exception e) //not good
              e.printStackTrace();
           return -1;
         }Rishi

  • How to make a code in which i have to detect 3 objects

    Hello everyone,
    I am new in Labview. I want to make a code in which i have to detect 3 objects and they are in different shapes (rectangle, triangle etc).
    1. How many objects in image.
    2. What is the size of each object in image
    3. At what position they are laying.
    4. Data array of histogram of each object.
    5. What is the color of each object.
    Please help me out. I am confused with the tool. Which tool i will use for this Vision Assistant or Vision Builder AI or if i use labview directly to make the code what steps should follow to make this code.
    Thanks
    Zeeshan

    Hello Zeeshan,
    this is Vanessa, AE from Germany. I really like to help you with your project but like the other members already told you it would be easier if you have a certain problem.
    Using your Shapes.jpg you have several options in the Vision Assistant. For identifiying circular objects of different size the tool "Find circular Edge" from the "Machine Vision" tab is the right choice (see screenshot attached). The result will be the center position and the radius so on. The pattern match function is not the right option because each of your objects has a different shape. In order to use this tool you need several copies of your object.
    Do you really need colored images? For most application it is sufficient to use grayscale images. Be aware that some functions are only available for grayscale and your program will speed up.
    Please tell us more details about your project.
    Kind regards,
    Vanessa
    Attachments:
    vision assistant.PNG ‏305 KB

  • Need help: represent edges/boundary of objects in RGB image?

    Hi everybody
    The edge detection has been used to detect the edges of objects.
    Now I want to represent/show edges/boundary of objects in RGB image.
    Thanks for any idea.
    mySIti

    Hey Dave -
    If I add them to a container and simply removeChild the container, will that avoid any memory leaks/problems?
    Wasn't sure if that was just an issue when eventListeners were involved.
    Thanks

  • How do I take an object from an image and save it so I can use it in other images?

    I am trying to figure out how to take an object from an image and save it so I can re-use it again in other pictures?  I know how to use the magic wand to select the object and place it in a blank image.... but I do not know how to re size the selected object or keep it for later use.  Basically I would like to use the object the same way that I use the graphics ... so I guess I am wondering if there is a way that I can make my own graphics... I have Elements Photoshop 13.  Thanks for any help/advice....  Jerrie

    Hi Jerrie,
    You can re-size using Transformation tool. Ctrl + T will give you a box to re-size the image or object.
    You can save these object as PNG file with Transparent layer. You can use these objects later in another projects.
    Regards,
    Sandeep

  • Render a swf object(contains an image) in navigator not possible

    Hy, I have a swf object that is an image(a circle). I have tried to render it in firefox but it doesnt render anything but I have tried with other swf object(not an image, an application) and it renders it ok. So can I render a swf file that is an image or is not possible? should I extract the image in it first to render on the navigator?
    Thanks

    Take a look at
    http://developers.sun.com/jscreator/learning/tutorials
    /2/file_upload.html#07.Thanks jetsons. That particular code sample (#7 in SJSC, #8 in Netbeans) shows only how to serialize a file to a different location on the server, not how to reference a file (not stored within the app forlder) to be rendered as a result of hyperlink click for example. Reading a little further in that page, it says:
    Be careful when putting the uploaded files in the web application as anyone can access the files by URL, such as http://localhost:29080/MyWebApplication/faces/upload/images/myPicture.gif.
    So, I am thinking that for added security, may be it is meant to be that I can't make an imageComponent reference a file outside of the wep app folder, but I am just guessing. In which case, I will simply have to store all such files within the web app folder before attempting to access them, unless someone has a better answer.

  • How to detect an object on a JPanel??

    Hi everyone,
    I have a question that might have been answered before but unfortunately I did not find it in Java forums.
    Actually I have a panel that my contains some objects with different shapes. I am looking for a way to detect these objects when the mouse is over them. (For example to get the class or the properties of these objects).
    Does any body have any idea how can I do this? Even if it is a link to previous answers I would be glad to have it.
    Sorry to bother and have a nice day.
    Pishi

    how are you adding these objects or whatever to the UI? are you painting them in yourself?Its a bit complicated.. I create some shapes in a drawing panel and I save them as a sort of hematoma (bruise) object that has this shape.
    In another panel I will upload this object and the user should detect this object by moving his mouse on the panel. (This Panel is not shown to the user and he has to detect it by the variation of the cursor head).
    someone has proposed a solution but do u have other ones? that would be welcome :)
    tnx

  • Unable to install supporting objects(custom CSS/Images) through SQL

    4.2.1
    Hi there,
    we have a Apex app which uses custom CSS/images loaded into shared objects CSS and image folders respectively. I followed the steps
    http://nerd.net.au/29-apex-application-express/general-application/122-include-images-with-supporting-objects-on-apex-export-import
    Now, this works fine when we manually import the application through application builder, it "prompts" if we want to install supporting objects, when yes is selected, everything gets installed.
    MY problem is we have an automated patching process where the .sql application file gets installed but the supporting objects are not. So I tried bundling the supporting object as a separate .sql file but got an error
    Testing options PL/SQL procedure successfully completed. declare * ERROR at line 1: ORA-20001: Package variable g_security_group_id must be set. ORA-06512: at "APEX_040200.WWV_FLOW_IMAGE_API", line 11 ORA-06512: at "APEX_040200.WWV_FLOW_IMAGE_API", line 31 ORA-06512: at
    The supporting object is a button. Do I need to set the application id or security group id or something else?
    begin
    wwv_flow_api.g_varchar2_table := wwv_flow_api.empty_varchar2_table;
    wwv_flow_api.g_varchar2_table(1) := '89504E470D0A1A0A0000000D494844520000009600000051080600000030EC5FEE000000097048597300000B1300000B1301009A9C1800000A4D6943435050686F746F73686F70204943432070726F66696C65000078DA9D53775893F7163EDFF7650F56';
    wwv_flow_api.g_varchar2_table(2) := '42D8F0B1976C81002223AC08C81059A21092006184101240C585880A561415119C4855C482D50A489D88E2A028B867418A885A8B555C38EE1FDCA7B57D7AEFEDEDFBD7FBBCE79CE7FCCE79CF0F8011122691E6A26A003952853C3AD81F8F4F48C4C9BD80';
    wwv_flow_api.g_varchar2_table(3) := '021548E0042010E6CBC26705C50000F00379787E74B03FFC01AF6F00020070D52E2412C7E1FF83BA50265700209100E02212E70B01905200C82E54C81400C81800B053B3640A009400006C797C422200AA0D00ECF4493E0500D8A993DC1700D8A21CA908';
    wwv_flow_api.g_varchar2_table(4) := '008D0100992847240240BB00605581522C02C0C200A0AC40222E04C0AE018059B632470280BD0500768E58900F4060008099422CCC0020380200431E13CD03204C03A030D2BFE0A95F7085B8480100C0CB95CD974BD23314B895D01A77F2F0E0E221E2C2';
    wwv_flow_api.g_varchar2_table(5) := '6CB142611729106609E4229C979B231348E7034CCE0C00001AF9D1C1FE383F90E7E6E4E1E666E76CEFF4C5A2FE6BF06F223E21F1DFFEBC8C020400104ECFEFDA5FE5E5D60370C701B075BF6BA95B00DA560068DFF95D33DB09A05A0AD07AF98B7938FC40';
    wwv_flow_api.g_varchar2_table(6) := '1E9EA150C83C1D1C0A0B0BED2562A1BD30E38B3EFF33E16FE08B7EF6FC401EFEDB7AF000719A4099ADC0A383FD71616E76AE528EE7CB0442316EF7E723FEC7857FFD8E29D1E234B15C2C158AF15889B850224DC779B952914421C995E212E97F32F11F96';
    wwv_flow_api.g_varchar2_table(7) := 'FD0993770D00AC864FC04EB607B5CB6CC07EEE01028B0E58D27600407EF32D8C1A0B91001067343279F7000093BFF98F402B0100CD97A4E30000BCE8185CA894174CC608000044A0812AB041070CC114ACC00E9CC11DBCC01702610644400C24C03C1042';
    wwv_flow_api.g_varchar2_table(8) := '06E4801C0AA11896411954C03AD804B5B0031AA0119AE110B4C131380DE7E0125C81EB70170660189EC218BC86090441C8081361213A8811628ED822CE0817998E04226148349280A420E988145122C5C872A402A9426A915D4823F22D7214398D5C40FA';
    wwv_flow_api.g_varchar2_table(147) := 'A514B7B6B6EA5AADA60B8582EAECEC54511471BD5EE7BEBE3EBF4E108FCA58FE9601580A68199FDAF12F8D1DDB5E3386221ADD8E3AF3CEC772A73505D60820C32BF0238E6DAF5D508DBAFFF2CFACE20C3E9A03E2789F3430B68D6DAF641BF33D8D6D63C0';
    wwv_flow_api.g_varchar2_table(148) := '1ADBC68035B68D016B6C1BDBC68035B6BD46B6FF3B0074B1DD40306DC6CD0000000049454E44AE426082';
    end;
    declare
        l_name   varchar2(255);
    begin
        l_name := 'logo.png';
      wwv_flow_api.create_or_remove_file(
         p_name=> l_name,
         p_varchar2_table=> wwv_flow_api.g_varchar2_table,
         p_mimetype=> 'image/png',
         p_location=> 'WORKSPACE',
         p_nlang=> '0',
         p_mode=> 'CREATE_OR_REPLACE',
         p_type=> 'IMAGE');
    end;
    /

    Thanks Fac586! I did follow the process on those lines and was able to successfully get the images, application installed. The CSS which just had
    body {
         background-color:#000000;
    }Was also applied. However, it for some reason does not work. Looks like the CSS is not getting loaded. When I delete the CSS and upload it again through the shared components->CSS folder, it works fine. Not sure what the solution is!
    Oh and by the way, thanks a ton for helping everyone!
    Cheers,
    Ryan

  • Managing multiple collision detection between objects(not necessarily circles)

    Hi.
    I´d like to know if there´s any good tutorial, or if somebody knows, a way, to manage a multiple collision detection with pixel level detection, for objects, not necessarily circles, irregular objects.
    Any help?

    Yes, and what about the speeds of each object?
    I was thinking something like this:
    var  _currentObj1SpeedX = obj1.speedX
    var  _currentObj1SpeedY = obj1.speedY
    obj1.speedX = obj1.speedX - obj2.speedX
    obj1.speedY = obj1.speedY - obj2.speedY
    obj2.speedX = obj2.speedX -  _currentObj1SpeedX
    obj2.speedY = obj2.speedY -  _currentObj1SpeedY
    Is it right?

  • Does acrobat has any option to read pdf content objects(stamps, layers, images etc) without using pl

    Does acrobat has any option to read pdf content objects(stamps, layers, images etc) without using plug-in in c#.net ?
    My requirement is read a pdf file and extract all the page objects(stampls, layers and images) along with its coordinates. Is it possible to get without using plug-ins in c#.net ?
    Please hlep me.

    These are very different things.
    JavaScript has some access to layers (called OCG). Layers are just names and have no coordinates to retrieve.
    Stamps may be annotations; there is some minimal access to these too I think. It may be hard to identify what is, and is not, a stamp even with a plug-in.
    Images are part of the actual page contents, and are only accessible to plug-ins.

  • Is it possible to clone an object from one image and paste it on another image?

    Is it possible to clone an object from one image and paste it on another image in Aperture?

    As Frank said,
    but Aperture has a nice clone tool - the drawback is, that it only works within one image.
    What I sometimes do - as a workaroud, when I want to use the clone brush, is to combine the image I want to clone from and the image I want to clone into, into one single image by printing them together to pdf as jpeg. Then I can clone from the second to the first, for example, to be able to add an fairy to a flower: Picking up the head of the fairy in the right image and brushing it into the left one. Occasionally I prefer the Aperture brush to the Photoshop lasso.

  • How to detect the object or session in a database with library cache lock

    Hi Everyone,
    We've been experiencing frequent and high time waits for this event: library cache lock.
    - What causes this?
    - Is there a way to detect the object being locked?
    (this doesnt show up in V$LOCK)
    - Is there a way to detect the session that is causing the lock? aka blocking session?
    (I can detect the objects being blocked, they show up in v$session)
    thanks,

    Similar post is here, maybe that helps already:
    library cache lock
    And You can read this as well:
    http://www.ixora.com.au/q+a/0101/19235723.htm

  • Algorithm to find the area and color  of the objects in an image

    Hello everyone,
    I have some problems in finding the segmented objects once i find the threshold , i want to find the area of the objects in the image . for example i have some lymphocytes in the image and i need to seperate them from the background by labelling them. can i seperate them by using the colour as well . please give some idea .
    my code till now is:
    int data = -1;
    try {
    System.out.println("Is the input a FloatImage ?");
    m_fi_in = (FloatImage)inputData[0];
    data = 0;
    catch (ClassCastException cce) {
    System.out.println("Not a FloatImage");
    data = -1;
    try {
    System.out.println("Is the input a Volume ?");
    m_vol_in = (Volume)inputData[0];
    data = 1;
    catch (ClassCastException cce2) {
    System.out.println("Not a Volume");
    data = -1;
    System.out.println(data);
    // For the FloatImage
    if (data == 0) {
    // For the Volume
    else if(data == 1) {
    System.out.println("Entering Volume for segmentation....");
    // Get target dimensions
    int depth = m_vol_in.getDepth();
    int height = m_vol_in.getHeight();
    int width = m_vol_in.getWidth();
    int region = 1;
    // Create a label structure
    // Consists of Image and region info
    m_label = new Label(m_vol_in);
    if(m_label == null) {
    System.out.println("Label could not be created");
    return false;
    // apply the threshold set by user
    float threshold = m_threshold.getValue();
    float maxi = m_threshold.getMaximum();
    float mini = m_threshold.getMinimum();
    // label the center of the volume in the region part of label as region 1
    m_label.setRegion(m_start_z.getValue(), m_start_y.getValue(), m_start_x.getValue(), region);
    System.out.println("Set starting voxel ("+m_start_z.getValue()+","+m_start_y.getValue()+","+m_start_x.getValue()+" to "+region);
    // Now process 8 partial volumina starting from a given point in the yz-plane in positive and then negative x directions
    // check the neighbours if they are already segmented and set the region in the target volume accordingly
    // do so for the whole yz-plane
    int x,y,z;
    int dir = 0; // the direction of the search. Only initialised here !
    System.out.println("Processing Volume in z++");
    for (z = m_start_z.getValue(); z < depth-1; z++) {
    for (y = m_start_y.getValue(); y < height-1; y++) {
    dir = 1;
    for (x = m_start_x.getValue(); x < width-1; x++) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    dir = -1;
    for (x = m_start_x.getValue(); x > 0; x--) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    for (y = m_start_y.getValue(); y > 0; y--) {
    dir = 1;
    for (x = m_start_x.getValue(); x < width-1; x++) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    dir = -1;
    for (x = m_start_x.getValue(); x > 0; x--) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    System.out.println("Processing Volume in z--");
    for (z = m_start_z.getValue(); z > 0 ; z--) {
    for (y = m_start_y.getValue(); y < height-1; y++) {
    dir = 1;
    for (x = m_start_x.getValue(); x < width-1; x++) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    dir = -1;
    for (x = m_start_x.getValue(); x > 0; x--) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    for (y = m_start_y.getValue(); y > 0; y--) {
    dir = 1;
    for (x = m_start_x.getValue(); x < width-1; x++) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    dir = -1;
    for (x = m_start_x.getValue(); x > 0; x--) {
    checkRegion(m_label, z, y, x, threshold, region, dir);
    // Apply result to output
    outputData[0] = m_label;
    else {
    return false;
    }

    search for cluster analysis
    spieler

  • Capturing Flex Display Objects as an Image

    Any help is appreciated
    I want a way to capture the Display Objects as an image and
    post it to a server
    Mostly I want to learn if Flex allow you to save objects in
    BitMap
    Thanks

    Check this out:
    http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitmapdata_tricks_and
    Tracy

Maybe you are looking for

  • Deletion of dimension is getting timed out in BPC 7.0 for NW

    Hi Experts, We have jus implemented SAP BPC 7.0 for NW.  We have copied standard APSHELL into ZAPSHELL and created user defined type of dimension.  We never used it and so thought of deleting.  While doing so from the action pane, we are getting mess

  • Webdesigning on a Mac - From a PC User's Prospective

    I just recently purchased a mac to start using for design...now, I've been using a PC since 1993 and eventhough I've heard mac's are best for every type of multimedia design/production, I purchased one and made the switch. Now, here's my issue: Worki

  • Help with HP Deskjet 6500 wireless connection

    My HP Deskjet 6500 worked perfectly via my wireless network until I turned off my SSID Broadcast. Now the printer SAYS it is connected to the wireless network, but I cannot print to it. The printer does not even show up as being on the network. There

  • SAP NetWeaver 7.1 CE SP05 Trial - SAP System is missing

    To all: I have completed the installation of SAP NetWeaver 7.1 CE SP05 Trial  locally to my PC. When I go into NWDC, I noticed that a SAP instance does not exist in the pulldown Windows -> Preferences - SAP AS Java.  When I tried to register my Insta

  • Unable to start OC4j

    Hi, I am not able to start OC4J on my unix box. It gives me below error. What might be the cause and how to resolve it. Looks like some port conflict but where should i check? $ ./oc4j -start Starting OC4J from /opt/webapps/obi_10.1.3.3.2/OracleBI/oc