vxFastCornersNode returns array of key points with x and y equals to zero

Hi, I’m trying to run vxFastCornersNode from VisionWorks API, without success so far. The current issue is that each key point in the result array has an x and y fields equal to zero.

Here is my code:

#include <tuple>
#include <iostream>

#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>

#include <NVX/nvx.h>
#include <NVX/nvx_opencv_interop.hpp>

#include <OVX/UtilityOVX.hpp>

int main(int argc, char *argv[]) {

  std::string image_file_path = PROJECT_SOURCE_DIR"/test/vlcsnap-2021-12-22-14h05m41s129.png";
  std::cout << image_file_path << "\n";
  cv::Mat image = cv::imread(image_file_path, cv::IMREAD_GRAYSCALE);

  assert(!image.empty());
  assert(image.rows > 0);
  assert(image.cols > 0);

  cv::resize(image, image, cv::Size(image.cols / 4, image.rows / 4), cv::INTER_LINEAR);

  vx_context context = vxCreateContext();
  NVXIO_CHECK_REFERENCE(context);

  vx_graph graph = vxCreateGraph(context);
  NVXIO_CHECK_REFERENCE(graph);

  vx_image input = nvx_cv::createVXImageFromCVMat(context, image);
  NVXIO_CHECK_REFERENCE(input);

  vx_float32 strength_thresh_init_value = 20.0f;
  vx_scalar strength_thresh = vxCreateScalar(context, VX_TYPE_FLOAT32, &strength_thresh_init_value);
  NVXIO_CHECK_REFERENCE(strength_thresh);

  vx_array keypoints = vxCreateVirtualArray(graph, VX_TYPE_KEYPOINT, 10000);
  NVXIO_CHECK_REFERENCE(keypoints);

  vx_size n_corners_init_value = 0;
  vx_scalar n_corners = vxCreateScalar(context, VX_TYPE_SIZE, &n_corners_init_value);
  NVXIO_CHECK_REFERENCE(n_corners);

  vx_node corner_detection_node = vxFastCornersNode(
      graph, input, strength_thresh, vx_true_e, keypoints, n_corners);
  NVXIO_CHECK_REFERENCE(corner_detection_node);

  // Ensure highest graph optimization level
  const char *option = "-O3";
  NVXIO_SAFE_CALL(vxSetGraphAttribute(graph, NVX_GRAPH_VERIFY_OPTIONS, option, strlen(option)));

  NVXIO_SAFE_CALL(vxVerifyGraph(graph));

  vxReleaseScalar(&strength_thresh);
  vxReleaseImage(&input);

  vx_image input_periodic = nvx_cv::createVXImageFromCVMat(context, image);
  NVXIO_CHECK_REFERENCE(input_periodic);

  NVXIO_SAFE_CALL(vxSetParameterByIndex(corner_detection_node, 0, (vx_reference)input_periodic));

  // Process graph
  NVXIO_SAFE_CALL(vxProcessGraph(graph));

  vxReleaseImage(&input_periodic);

  vx_int32 n_corners_value = 0;
  NVXIO_SAFE_CALL(vxReadScalarValue(n_corners, &n_corners_value));

  vx_size num_items = 0ul;
  NVXIO_SAFE_CALL(vxQueryArray(keypoints, VX_ARRAY_ATTRIBUTE_NUMITEMS, &num_items, sizeof(num_items)));

  vx_size i, stride = 0ul;
  void *base = NULL;

  NVXIO_SAFE_CALL(vxAccessArrayRange(keypoints, 0, num_items, &stride, &base, VX_READ_ONLY));

  for (i = 0; i < 10; i++) {

    std::cout
        << "x: " << vxArrayItem(nvx_keypointf_t, base, i, stride).x << " "
        << "y: " << vxArrayItem(nvx_keypointf_t, base, i, stride).y << " "
        << "scale: " << vxArrayItem(nvx_keypointf_t, base, i, stride).scale << " "
        << "strength: " << vxArrayItem(nvx_keypointf_t, base, i, stride).strength << " "
        << "tracking_status: " << vxArrayItem(nvx_keypointf_t, base, i, stride).tracking_status << " "
        << "orientation: " << vxArrayItem(nvx_keypointf_t, base, i, stride).orientation << " "
        << "\n";

  }
  vxCommitArrayRange(keypoints, 0, num_items, base);

  std::cout
      << "num_items: " << num_items << " "
      << "n_corners_value: " << n_corners_value << " "
      << "stride: " << stride << " "
      << "\n";

  return 0;
}

Here is the output:

/tmp/tmp.DpoYHlrS19/test/vlcsnap-2021-12-22-14h05m41s129.png
x: 0 y: 0 scale: 0 strength: 33 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 79 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 22 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 27 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 33 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 31 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 33 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 21 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 27 tracking_status: 1 orientation: 0 
x: 0 y: 0 scale: 0 strength: 22 tracking_status: 1 orientation: 0 
num_items: 5128 n_corners_value: 5128 stride: 28 

There are several things I’m not sure in:

  1. If I have to release all the refs used during the graph creation before its execution?
  2. What does tracking_status=1 mean in the context of corner detection? There is no tracking involved, so why it was set to 1?

Many thanks for any hint!

Best regards,
Alex

Sorry for the late response, is this still an issue to support? Thanks

Hi!
Yes, it is still an issue.

Hi slovak194,
follow our demo to test:
1)/usr/share/visionworks/sources/, go to this DIR
2) sudo ./install-samples.sh ~/
you will see result like this

  1. cd ~/VisionWorks-1.6-Samples/
    4)sudo make -j6
    all sample can be compiled

5)vxFastCornersNode is in samples\GraphMode\graph_mode_stabilizer.cpp
in bin/ nvx_demo_video_stabilizer
6)run this binary

7)reference graph_mode_stabilizer.cpp to do more test.

Hi, @Jeffli !
Thank you for your suggestion, but on my end this sample is missing. I’m trying to find out why now. Could you please share this sample here if possible?

nvidia@dev0:~/VisionWorks-1.6-Samples$ ll samples/
total 28
drwxrwxr-x  7 nvidia nvidia 4096 Jan  3 13:30 ./
drwxrwxr-x 10 nvidia nvidia 4096 Jan  3 18:12 ../
drwxrwxr-x  3 nvidia nvidia 4096 Jan  3 13:30 nvgstcamera_capture/
drwxrwxr-x  3 nvidia nvidia 4096 Jan  3 13:30 object_tracker_nvxcu/
drwxrwxr-x  3 nvidia nvidia 4096 Jan  3 13:30 opencv_npp_interop/
drwxrwxr-x  3 nvidia nvidia 4096 Jan  3 13:30 opengl_interop/
drwxrwxr-x  3 nvidia nvidia 4096 Jan  3 13:30 player/

nvidia@dev0:~$ apt list --installed | grep libvisionworks-samples

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libvisionworks-samples/stable,now 1.6.0.501 arm64 [installed]
nvidia@dev0:~$ dpkg -L libvisionworks-samples | grep graph_mode_stabilizer
nvidia@dev0:~$ 

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.